Jump to content

Lisp to convert a MLINE to a single PLINE


isutheparambil

Recommended Posts

Hi,

 

I am looking for a lisp that can convert MULTILINE to a single PLINE.

The lisp that converting the same MULTILINE to 2 PLINE already I found from the attached post.clip.jpg

But I need that multi line in to a single pline-NOT double pline.

If someone have any idea, please share with me...

:):):)

Link to comment
Share on other sites

Remark looks like original centreline of mline, not sure what "co-ords" of mline gives also need to check top, bottom and zero.

 

; converts mline to pline note uses mline vertices does not take
; into account top or bottom offset
; By Alan H Aug 2017

(defun c:test ( / co-ords ent co-ordsxy xy oldsnap)

(setq oldsnap (getvar "osmode"))

(setq ss (ssget (list (cons 0 "Mline")))) ; pick only mlines
(if (/= ss nil)
(progn
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (- x 1)))) ; get mlines
(setq co-ords 
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ent) ; get co-ordinates of mline
"Coordinates"
)
)
)
)

; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 3)) ; mlines have a z value hence / 3
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy)) ; make a list of co-ordinates
(setq I (+ I 3))
)

(setvar "osmode" 0)
(command "_pline")
(while (= (getvar "cmdactive") 1 )
(repeat (setq y (length co-ordsxy))
(command (nth (setq y (- y 1)) co-ordsxy)) ; read list of points
)
(command "")
)
(setq co-ordsxy nil) ; reset to do again
(command "erase" ent "")
)
)
)
(setvar "osmode" oldsnap) ; reset snap mode
)

Edited by BIGAL
Link to comment
Share on other sites

BIGAL,

 

That was great and quite nice.

 

Still there is a problem existing that.....

 

1. MLINE still existing (the MLINE i need to delete)

2. The newly created PLINE that is not the center line of MLINE.(in this case I am looking the cener line of MLINE as a PLINE, and the base MLINE shoulld be replaced with new PLINE)8)

 

Hope you got my requirements.:):):)

Link to comment
Share on other sites

Anyway the MLINE contains odd numbers like 3,5,7,9....etc.. Mlines, it will take the center line as a PLINE.( But not with the even numbers).

As you mention, if Delete is harder to add with, then easly can delete the remain MLINE by Erase command with a 'select similar' option.

 

Thanks all of you for a good support:D:D:D

Edited by isutheparambil
Link to comment
Share on other sites

Top or bottom refers to a mline being to the left or right offset. But the code will put the pline on the left or right not in middle when Top or Bot is used.

Link to comment
Share on other sites

Yes BIGAL,

 

You are right.

But the one which created finally that was not able to select by a window or cross window, but by a single click only.

Any way both programs are very helpful for me.

 

I request you to one thing that can possible with a selection by cross window or widow instead the one working with the single click selection is much appreciate and more helpful even that PLINE is not assigned to middle also.

 

Thanks for all again..:):):)

Link to comment
Share on other sites

BIGAL,

 

Thank you so much....

That was great....

 

That what i need..:D:D:D

 

The result PLINE which taking the justification of MLINE..:):):):D:D:D

 

Really nice....

I really appreciate you...

 

Thanks a lot BIGAL....8)8)8)

Link to comment
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
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...