Lisp to create a MLine Style using parallel polylines as reference

Lisp to create a MLine Style using parallel polylines as reference

aitorm
Advocate Advocate
945 Views
3 Replies
Message 1 of 4

Lisp to create a MLine Style using parallel polylines as reference

aitorm
Advocate
Advocate

Hi there!

 

I need to create several MLine styles and I find that it is very slow to create them. I was guessing if it would be possible to create a LISP that uses some lines I previously drew for reference to create a new MLine. For example, LISP that reads the polyline linetype and color and its offset distance from a base one and then creates a MLine Style that copies that info.

 

¿Do anyone knows how to do it?

0 Likes
Accepted solutions (1)
946 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor
Accepted solution

Have a look at this, depending on what your measuring I use a drag over method pick 2 points and use a ssget "F" so get two objects can then do a VL  intersectwith for 1st point, then a VL closestpointto so distance pt1 pt2 is the offset.

 

Replace in the while below. using "F" Fence can do multiple parallel lines in one go. 

 

; make mline 
; By alan H oct 2020
; Set to bylayer at moment
; Thanks to FIXO for original code

(defun c:makml ( / lst1 lst2 lst desc MLINE_STYLE_NAME )
(setq 	MLINE_STYLE_NAME (getstring "\nEnter mline name ")
		desc (getstring "\nEnter description ")
)
(while (setq off (getreal "\Enter offset Enter to finish " ))
	(setq lst (cons off lst))
)
(if (= desc nil)(setq desc MLINE_STYLE_NAME))
(setq lst1
	(list '(0 . "MLINESTYLE")
		'(100 . "AcDbMlineStyle")
		(cons 2 MLINE_STYLE_NAME)
		'(70 . 0)
		(cons 3 desc)
		'(62 . 256)
		'(51 . 1.5708)
		'(52 . 1.5708)
		'(71 . 4)
	)
)
(setq x (length lst))
(repeat x
	(setq lst2 (list 
		(cons 49 (nth (setq x (- x 1)) lst))
		(cons 62 256)
		(cons 6 "BYLAYER")
		)
	)
	(setq lst1 (append lst1 lst2))
)
(if
	(not (dictadd
		(cdar (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
		MLINE_STYLE_NAME
		(entmakex lst1)
		)
	)
	(Alert "Impossible to create mline style\n perhaps this was exist earlier")
)
(setvar 'cmlstyle MLINE_STYLE_NAME)
(princ)
)
(c:makml)
Message 3 of 4

aitorm
Advocate
Advocate

This code is very helpful and make me rethink what I want. Just choosing the distances from the command line works for me, so the only think I would need to do is to be able to choose also the belonging linetypes.

 

But I have no idea how to face this. Can anyone help me?

0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

Its a command called MLSTYLE.

0 Likes