Jump to content

Recommended Posts

Posted

How can I convert a series of line sgments to a polyline, or draw them as a pline by modifying the following code:

 
(setq p1(cadr (car l)))
(while (/= l nil)
(setq l(cdr l)) 
(setq p2(cadr (car l))) 
(command "line"  "_NON" p1 "_NON" p2 "") 
(setq p1 p2) 
)

Thanking in advance,

Aloy

Posted

Try this code, if you need to make the pline closed hit "CL" at the end

 
(defun C:demo()
(setq osm (getvar "osmode")) 
(setvar "osmode" 0) 
(command "._pline")
(while (= 1 (logand 1 (getvar "cmdactive")))
(command pause))
(setvar "osmode" osm) 
(princ) 
)

 

~'J'~

Posted

Hi Fixo,

The code you gave works fine on it own just like pline in autoCad. What I need is, to extract the point from the list, l ,when prompted to give the point.

Regards,

Aloy

Posted

Try instead

 
(defun C:demo(/ closed osm ptlist)
(setq osm (getvar "osmode")) 
(setvar "osmode" 0)
(setq ptlist [ your points ])
(setq closed T ;|or nil if open|
(command "._pline")
(mapcar 'command ptlist)
(if closed 
(command "CL")
(command "")
(setvar "osmode" osm)
(princ)
)

Posted

aloy,

From your code, the list must be something like ((a (x y z)) (b (u v w)) ...

In this case, this code will draw a Polyline instead of Lines.

(command "PLINE")
(foreach x l
 (command "_non" (cadr x))
 )
(command "")

Posted (edited)

How can I convert a series of line sgments to a polyline

 

One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set, example:

 

(defun c:FOO (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "LINE"))))
   (command "._pedit" "multiple" ss "" "y" "")
   (prompt "\n** Nothing selected ** ")
   )
 (princ)
 )

... You can tailor this how you like, if you wanted to join the lines, etc..

 

HTH

Edited by BlackBox
Posted

Stefan,

Thanks a lot. Fantastic.

Regards,

Aloy

Posted

Hi RenderMan,

It does not work. It asks to select and at the end does not convert. If you like I can post the list to draw the lines and you may try.

Regards,

Aloy

Posted

How can I convert a series of line sgments to a polyline

 

One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set

 

Hi RenderMan,

It does not work. It asks to select and at the end does not convert. If you like I can post the list to draw the lines and you may try.

 

To reiterate... The function prompts the user for a Selection Set of lines that already exist within the drawing (and not a list of points), then converts the a valid Selection Set to Polylines. This function does not accept any arguments (i.e., a list of points).

 

You've mentioned different tasks in this thread; this offering is by no means an answer for each of them.

Posted

Hi RenderMan,

Yes, what 'pedit' does is to convert lines to individual polilines. That's what happened when I drew the series of lines which are connected, end to end, and use c:foo function to convert them. However few understood my intension though the title may not explain fully.

Regards,

Aloy

Posted
what 'pedit' does is to convert lines to individual polilines. That's what happened when I drew the series of lines which are connected, end to end

 

I can't help thinking that you are not using Pedit to its full extent.

 

If I had a series of lines which are connected in groups, I would start the command Pedit. then before selecting polyline, I would type M for multiple. To select objects, I would do a window selection, then Y to convert lines and arcs to polylines. Choosing the option J to join, then accept the fuzz distance of 0.00. All joining lines are converted to joined-up polylines.

 

You can do it by Lisp, but it seems to be re-inventing the wheel. Perhaps you should post your drawing.

Posted

Hi, eldon,

Thank you very much for enlighting about full extent of pedit. It works. In the real world these lines constitute centre line of a road which will be drawn on the AutoCAD suyvey plan; hence there will be many other line making it difficult to select by a window.

I will post the drawing on another thread to prepare a table of coordinates.

Regards,

Aloy

Posted
In the real world these lines constitute centre line of a road which will be drawn on the AutoCAD suyvey plan; hence there will be many other line making it difficult to select by a window.

 

If you are sure that only the lines to form the polyline are connected, then when asked to select objects, type "all". Everything will be selected, but only touching lines will be joined to make the polyline. :D

Posted
I can't help thinking that you are not using Pedit to its full extent.

 

Thanks for the clarification, eldon. :thumbsup:

 

Aloy - To reiterate, this was mentioned back in post #7, where I also included a link to the Command's documentation for your use:

 

One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set, example:

 

 

... You can tailor this how you like, if you wanted to join the lines, etc..

Posted

Sorry RenderMan,

I did not notice the last line in the posting No. 7; now I am clear.

Regards,

Aloy

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...