Jump to content

Getting a length and creating a line with it.


Recommended Posts

Dears,

 

Someone knows how I can get a length of one arc or object (more than one) and construct a line after it with all lenghts separated for a specific space between each one.

 

Comprimento.jpg

 

Thanks

Link to post
Share on other sites

Noop, a large quantity of them, so normally polylines or circles... It's necessary to get it and change the length on a line (by each one, not the total) with their measured lengths...

Link to post
Share on other sites

No arcs but plines?

(Defun c:demo ( / pt ent len )
(if (setq pt nil ss (ssget))
 (repeat (setq i (sslength ss))
   	(setq ent (ssname ss (Setq i (1- i)))
   	      len (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent )))
(if (null pt)
  	(progn (setq pt (getpoint "\nPick start point:"))
		(Setq dst (getdist pt "\nDistance between lines:")))
	(setq pt (polar pt 0.0 dst)))
(entmakex (list (cons 0 "LINE")
                 (cons 10 pt)
                 (cons 11 (polar pt (* pi 1.5) len))))
   )
 )(princ)
 )

Link to post
Share on other sites

Ok, pBe... It's working very nice!!!... Thank you!!!... On "simple" lines you helped me a lot!!!... Some friends and I spent much time doing it manually!!!...

Link to post
Share on other sites
Ok, pBe... It's working very nice!!!... Thank you!!!... On "simple" lines you helped me a lot!!!... Some friends and I spent much time doing it manually!!!...

 

You are welcome, Glad it works for you.

 

Happy to help

 

Cheers :)

Link to post
Share on other sites

How about this:

 

(defun C:test (/ ss e l i p d)
(setq ss (ssget "_:L" '((0 . "CIRCLE,ARC,LWPOLYLINE")))
     p  (getpoint "\nPick a point")
     d  (getdist p "\nDistance between lines ; ")
) 
(repeat (setq i (sslength ss))
 (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))
       l (cond
           ((vlax-property-available-p e 'length) (vla-get-length e))
    ((vlax-property-available-p e 'circumference) (vla-get-circumference e))
    ((vlax-property-available-p e 'arclength) (vla-get-arclength e))
          )
 )
 (entmake 
   (list 
    '(0 . "LINE")
     (cons 10 p)
     (cons 11 (polar p (* pi 1.5) l))
  )  
 )
 (setq p (polar p 0 d))
)
(princ)
)

Link to post
Share on other sites
Dear pBe,

 

I got some troubles with the command, could you help-me looking the file attached to try to solve or try to tell me what to do!?... Thanks...

 

As far as i can tell the demo lisp will give you the correct length.

 

Troubles? In what way CafeJr? Do you select all the entities in one go? we can modify the code to recognize which lines goes where if that's how you want it.

 

Here you go:

(Defun c:demo (/ pt ent len sp ep pt1)
 (if (setq pt nil
    ss (ssget '((0 . "CIRCLE,ARC,*LINE")))
     )
   (repeat (setq i (sslength ss))
     (setq ent	(ssname ss (Setq i (1- i)))
    len	(vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
    sp	(Vlax-curve-getstartpoint ent)
    ep	(Vlax-curve-getendpoint ent)
     )
     (if (null pt)
(setq pt (getpoint "\nPick start point:"))
     )

     (entmakex
(list (cons 0 "LINE")
      (cons 10
	    (setq pt1 (list (min (Car sp) (car ep)) (cadr pt)))
      )
      (cons 11 (polar pt1 (* pi 1.5) len))
)
     )
   )
 )
 (princ)
)

Edited by pBe
Add lisp code
Link to post
Share on other sites

pBe, I can't try it right now... tomorrow I'll do it... So, the trouble it's the length on original polyline is different of the line created, as the second file that I showed here!... I don't know why it happens, so, the length in lines don't match with the plines...

Link to post
Share on other sites

This will work as long as entities does not overlap and arranged horizontally.

 

(defun C:test (/ ss p l i d v)
(setq ss (ssget "_:L" '((0 . "CIRCLE,ARC,*OLYLINE")))
     p  (getpoint "\nPick a point")
     d  (getdist p "\nDistance between lines ; ")
) 
(foreach x
 (vl-sort
   (repeat (setq i (sslength ss))
       (setq i (1- i)
             l (cons (ssname ss i) l)
       )
   )
   (function 
     (lambda (x1 x2) 
       (< 
         (car 
           (cdr 
             (assoc 10 
               (entget x1)
             )
           )
         )
         (car 
           (cdr 
             (assoc 10 
               (entget x2)
             )
           )
         )
       )
     )
   )
 )
(setq v (vlax-ename->vla-object x)
       l (cond
           ((vlax-property-available-p v 'length) (vla-get-length v))
           ((vlax-property-available-p v 'circumference) (vla-get-circumference v))
           ((vlax-property-available-p v 'arclength) (vla-get-arclength v))
         )
 )
 (entmake 
   (list 
     (cons 0  "LINE")
     (cons 10 p)
     (cons 11 (polar p (* pi 1.5) l))
   )  
 )
 (setq p (polar p 0 d))
)
(princ)
)
(vl-load-com)

Link to post
Share on other sites
:thumbsup: :notworthy: Now it's working... Thank you pBe and jandiala, it help me a lot to do one application!... I'm grateful!!!... I got only one line on the file 2 (attached on another post) that the length don't mach, but no problem...
Link to post
Share on other sites
:thumbsup: :notworthy: Now it's working... Thank you pBe and jandiala, it help me a lot to do one application!... I'm grateful!!!....

 

Glad it works for you.

 

I got only one line on the file 2 (attached on another post) that the length don't mach, but no problem...

And what would that be this time CafeJr?

Link to post
Share on other sites
So, to you look what I'm telling see the attached file!... Item 103...

 

As jdiala said. as long as entities does not overlap. simply put, there are 2 Items at the 103rd position . so there actually 135 and 134

 

 

pBe, it's possible check the length before write it?... To confirm the length data?!...

 

Why do you need to check the length? the program does that for you.

Link to post
Share on other sites
As jdiala said. as long as entities does not overlap. simply put, there are 2 Items at the 103rd position . so there actually 135 and 134

Why do you need to check the length? the program does that for you.

 

pBe, Thanks a lot to help!!!... It's working as good as I need!... I'm really shamed about it, 2 entities on items 103rd cause I didn't saw it!... Ok, my mistake!... About to check is only one way to confirm how many objects was read and drawed, some thing that could help to avoid it, it's possible another guy repeat the same mistake...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...