SlideShare a Scribd company logo
1 of 1
;==============================================================================
;Function: to calculate the total length of the selected objects (line, curve or arc)
;==============================================================================
(defun c:ts() ;the command "ts"
(vl-load-com) ;load the microsoft activeX support
(setq tleng 0) ;set the initial value of variant "tleng"
(setq s (ssget)) ;pick up the measured objects
(setq n (sslength s)) ;count the selection
(setq index (- n 1)) ;set the loop index
(setq lens (list 0)) ;construct the object length list
(repeat n ;start the loop to go through the selection
(setq ent (ssname s index)) ;select the item in the selection
(setq index (- index 1)) ;prepare for the next item with variant index
(setq curve-obj (vlax-ename->vla-object ent)) ;convert the item to activeX object to calculate the length
(setq leng (vlax-curve-getDistAtParam ;get the length and store it to variant leng
curve-obj
(vlax-curve-getEndParam curve-obj)
)
)
(setq lens (append lens (list leng))) ;send the length to list "lens"
(setq tleng (+ tleng leng)) ;add the length to variant "tleng"
(princ leng) ;print the current object's length
(princ "n") ;return in the AutoCAD command line
)
(setq lens (vl-sort lens '<)) ;sort the list "lens" in ascending order
(princ (strcat "n 总共计算" ;print the total length and the maximum and
;minimum length of the selected objects
(itoa n) "个对象,n 总长度为 "
(rtos tleng 2 6)
"n 平均值为 "
(rtos (/ tleng n) 2 6)
"n 最小值为 "
(rtos (cadr lens) 2 6)
"n 最大值为 "
(rtos (last lens) 2 6)
)
)
(princ)
)

More Related Content

What's hot

Debugging JavaScript with Chrome
Debugging JavaScript with ChromeDebugging JavaScript with Chrome
Debugging JavaScript with ChromeIgor Zalutsky
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of listElavarasi K
 
RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術名辰 洪
 
Oops in c++
Oops in c++Oops in c++
Oops in c++DravidSh
 
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜DeNA
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp
 
What they don't tell you about JavaScript
What they don't tell you about JavaScriptWhat they don't tell you about JavaScript
What they don't tell you about JavaScriptRaphael Cruzeiro
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyYasuharu Nakano
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in DepthC4Media
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojureRoy Rutto
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计Alipay
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017名辰 洪
 
Examples of sql queries
Examples of sql queriesExamples of sql queries
Examples of sql queriesKishan Pant
 
Python queue solution with asyncio and kafka
Python queue solution with asyncio and kafkaPython queue solution with asyncio and kafka
Python queue solution with asyncio and kafkaOndřej Veselý
 

What's hot (20)

Debugging JavaScript with Chrome
Debugging JavaScript with ChromeDebugging JavaScript with Chrome
Debugging JavaScript with Chrome
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術
 
Oops in c++
Oops in c++Oops in c++
Oops in c++
 
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
 
Uts
UtsUts
Uts
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223
 
JVM Architecture - Java
JVM Architecture - JavaJVM Architecture - Java
JVM Architecture - Java
 
What they don't tell you about JavaScript
What they don't tell you about JavaScriptWhat they don't tell you about JavaScript
What they don't tell you about JavaScript
 
Cpp
Cpp Cpp
Cpp
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
C++ programs
C++ programsC++ programs
C++ programs
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojure
 
กลุ่ม6
กลุ่ม6กลุ่ม6
กลุ่ม6
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
Examples of sql queries
Examples of sql queriesExamples of sql queries
Examples of sql queries
 
Python queue solution with asyncio and kafka
Python queue solution with asyncio and kafkaPython queue solution with asyncio and kafka
Python queue solution with asyncio and kafka
 

Similar to ts

Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++nsm.nikhil
 
Javascript Arrays
Javascript ArraysJavascript Arrays
Javascript Arraysshaheenakv
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Please implement in Java. comments would be appreciated 5.pdf
Please implement in Java. comments would be appreciated 5.pdfPlease implement in Java. comments would be appreciated 5.pdf
Please implement in Java. comments would be appreciated 5.pdffms12345
 
Grand centraldispatch
Grand centraldispatchGrand centraldispatch
Grand centraldispatchYuumi Yoshida
 
連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」matuura_core
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)Yeshwanth Kumar
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
Testing in those hard to reach places
Testing in those hard to reach placesTesting in those hard to reach places
Testing in those hard to reach placesdn
 
Managing Complex UI using xState
Managing Complex UI using xStateManaging Complex UI using xState
Managing Complex UI using xStateXavier Lozinguez
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfarihantmobileselepun
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the mastersAra Pehlivanian
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Stephen Chin
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++vidyamittal
 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Getachew Ganfur
 

Similar to ts (20)

Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++
 
Javascript Arrays
Javascript ArraysJavascript Arrays
Javascript Arrays
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Please implement in Java. comments would be appreciated 5.pdf
Please implement in Java. comments would be appreciated 5.pdfPlease implement in Java. comments would be appreciated 5.pdf
Please implement in Java. comments would be appreciated 5.pdf
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Grand centraldispatch
Grand centraldispatchGrand centraldispatch
Grand centraldispatch
 
連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Testing in those hard to reach places
Testing in those hard to reach placesTesting in those hard to reach places
Testing in those hard to reach places
 
Managing Complex UI using xState
Managing Complex UI using xStateManaging Complex UI using xState
Managing Complex UI using xState
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++
 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01
 

ts

  • 1. ;============================================================================== ;Function: to calculate the total length of the selected objects (line, curve or arc) ;============================================================================== (defun c:ts() ;the command "ts" (vl-load-com) ;load the microsoft activeX support (setq tleng 0) ;set the initial value of variant "tleng" (setq s (ssget)) ;pick up the measured objects (setq n (sslength s)) ;count the selection (setq index (- n 1)) ;set the loop index (setq lens (list 0)) ;construct the object length list (repeat n ;start the loop to go through the selection (setq ent (ssname s index)) ;select the item in the selection (setq index (- index 1)) ;prepare for the next item with variant index (setq curve-obj (vlax-ename->vla-object ent)) ;convert the item to activeX object to calculate the length (setq leng (vlax-curve-getDistAtParam ;get the length and store it to variant leng curve-obj (vlax-curve-getEndParam curve-obj) ) ) (setq lens (append lens (list leng))) ;send the length to list "lens" (setq tleng (+ tleng leng)) ;add the length to variant "tleng" (princ leng) ;print the current object's length (princ "n") ;return in the AutoCAD command line ) (setq lens (vl-sort lens '<)) ;sort the list "lens" in ascending order (princ (strcat "n 总共计算" ;print the total length and the maximum and ;minimum length of the selected objects (itoa n) "个对象,n 总长度为 " (rtos tleng 2 6) "n 平均值为 " (rtos (/ tleng n) 2 6) "n 最小值为 " (rtos (cadr lens) 2 6) "n 最大值为 " (rtos (last lens) 2 6) ) ) (princ) )