Distance and length entities polyline

Distance and length entities polyline

tuanvmvpn2012
Explorer Explorer
1,010 Views
11 Replies
Message 1 of 12

Distance and length entities polyline

tuanvmvpn2012
Explorer
Explorer

Hi All.

 

I'm beginner AutoLISP, now I want to measure distance and give length total entities polylines by LISP code, Is there any one help me to resolves it. That such as Drawing attached file

 

Many thanks.   

0 Likes
Accepted solutions (1)
1,011 Views
11 Replies
Replies (11)
Message 2 of 12

devitg
Advisor
Advisor

Despite you can use a LISP , also you can use the DATAEXTRACTION command 

Message 3 of 12

paullimapa
Mentor
Mentor

you can find many things on-line by just googling:

TotalLength | AutoCAD | Autodesk App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 12

Sea-Haven
Mentor
Mentor

Always include "AUTOCAD" when googling.

 

"Get total length of lines Autocad"

Message 5 of 12

-didier-
Advisor
Advisor
Accepted solution

Bonjour @tuanvmvpn2012 

 

If I understood the request correctly according to the drawing provided.
I think it’s something of the kind you expect.

Did I understand correctly?
If yes I will give you the code, if not I ask for further explanation.

 

Amicalement

 

 

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

Message 6 of 12

tuanvmvpn2012
Explorer
Explorer

Thanks all replied;

I have alot of cross section to creat, so I mean want to creat cross section from files (txt, csv....) or contour, I want to note the distance of segments one by one and total length in other row the same in my drawing.  

If you have code to do that, pls help me.

 

Thanks you in advance

 

0 Likes
Message 7 of 12

ВeekeeCZ
Consultant
Consultant

Are you really learning or is it just an empty phrase? 

If so, where is some attempt of yours? Where did you get stuck and need to advise some direction?

 

BTW with QDIM is fairly quick and easy to achieve such a result, see THIS 

Message 8 of 12

-didier-
Advisor
Advisor

Bonjour @tuanvmvpn2012 

 

I don’t understand about you talking about CSV file.

Is that a new question?
I also understand that it is not the distances that must be written,
but the differences between abscises, we agree?

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 9 of 12

-didier-
Advisor
Advisor

Bonjour @tuanvmvpn2012 

 

You seem to have sent two messages to ask your question.
One is an old message from 2002 that you relaunched.
It wasn’t a good idea.
You didn’t talk here about putting the data in an external file.
However, it seems that you have been answered, and in this case we thank you for marking the subject as resolved.

I’m talking about this message:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-polyline-length/m-p/11445325#M43... 

 

Amicalement

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 10 of 12

Sea-Haven
Mentor
Mentor

The post heading appears to be totally misleading.

 

"So I mean want to create cross section from files (txt, csv....) or contour."

 

Answer is CIV3D or other software, eg  Civil Site Design.

 

Yeah there is some other stuff out there, start googling.

0 Likes
Message 11 of 12

tuanvmvpn2012
Explorer
Explorer

Dear Sir;

Thanks for your replied

I'm sorry for replying to your message late. The video you gave is my purpose. I wish to your support and guidance.

I hope, I can have your code,

Thank you in advance.

 

0 Likes
Message 12 of 12

calderg1000
Mentor
Mentor

Regards @tuanvmvpn2012 

Try this code, although maybe a little late...

(defun c:DtPerf (/ pt_list s)
  (setq s (car (entsel "\nSelect Profile (Lwpolyline)")))
  (dtS s)
)

(defun dtS (s / lp ht p n d pm x tx)
  (setq
    lp (mapcar
         'cdr
         (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget s))
       )
    ht 0.3
    p  (getpoint "Pick Point: ")
    n  0
    da 0
  )
  (repeat (1- (length lp))
    (setq dp (distance (nth (1+ n) lp) (nth n lp))
          da (+ da (distance (nth (1+ n) lp) (nth n lp)))
          pm (mapcar '/ (mapcar '+ (nth (1+ n) lp) (nth n lp)) '(2. 2.))
    )
    (setq ltx (list (rtos dp 2 2) (strcat "\n\n" (rtos da 2 2))))
    (foreach x ltx
      (setq tx (entmakex (list '(0 . "text")
                               (cons 100 "AcDbEntity")
                               (cons 100 "AcDbText")
                               (cons 10 (list (car pm) (cadr p)))
                               (cons 1 x)
                               (cons 40 ht)
                               (cons 72 1)
                               (cons 11 (list (car pm) (cadr p)))
                               (cons 73 1)
                         )
               )
      )
    )
    (setq n (1+ n))
  )
  (princ)
)

Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes