Jump to content

Lisp convert several polyline with width to hatch solid?


Recommended Posts

Posted

hELLO,

Is there a lisp that could change several Polyline with random thickness to Hatch pattrene Solid, with a lisp, when u type command P2H

see attachment.

test2.dwg

Posted

Hello Ronjonp, the lisp is almost perfect, but can u make it, so by command P2H, it autom. select all Polyline and make the hatch solid? like attachment?

Posted
(defun c:mpolyoutlineh (/ b d e h i s)
  (if
    (setq s (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
     (progn (initget "Yes No")
	    (setq d (/= "No" (getkword "\nDelete Original? [Yes/No] <Yes>: ")))
	    (setq b (vlax-get (vla-get-activedocument (vlax-get-acad-object))
			      (if (= (getvar 'cvport) 1)
				'paperspace
				'modelspace
			      )
		    )
	    )
	    (repeat (setq i (sslength s))
	      ;; RJP mod to apply solid hatch to outlines
	      ;; Odd results if you have self intersecting plines
	      (foreach c (lm:polyoutline (setq e (ssname s (setq i (1- i)))))
		(cond ((setq h (vlax-invoke b 'addhatch achatchobject "SOLID" :vlax-true))
		       (vlax-invoke h 'appendouterloop (list (vlax-ename->vla-object c)))
		       (vla-evaluate h)
		       (vla-put-layer h (cdr (assoc 8 (entget e))))
		      )
		)
	      )
	      (if d
		(entdel e)
	      )
	    )
     )
  )
  (princ)
)

 

Posted (edited)

Hello Ronjonp,

 

I load the lisp and type mpolyoutlineh, then the lisp still ask me to select te object etc? but doesn't automatic convert the Pline to Hatch solid?

it would be great, if the lisp not asking all the questions.

Edited by CAD
Posted

Not sure .. works here? Are you calling the correct code ? c:mpolyoutlineh 

image.thumb.png.434ef2416c75a85ff38b3f65adabe89f.png

Posted (edited)
1 hour ago, ronjonp said:

when i type mpolyoutlineh  it ask me to select objects? is there any settings i not have done?

 

Edited by CAD
Posted

I'm confused. The prompt to select objects is to select the polylines you want to convert.

You also have to load all of the code from Lee's site as it is the base of the program.

Posted (edited)

sorry confuse You, but my idea is, when i type mpolyoutlinethe lisp Lee or the yours it turns all Polylines to outline and instant change to Hatch solid. so i dont have to select the polylines. Just 1 lisp do all the work, with one command like mpolyoutlineh

Edited by CAD
Posted (edited)

still asking select objects, iam using acad 2017 is that maybe a problem?

 

Command:  MPOLYOUTLINEH

Select objects: Specify opposite corner: 3 found

Select objects: Specify opposite corner: 3 found (3 duplicate), 3 total

Select objects:
Delete Original? [Yes/No] <Yes>:

Edited by CAD
Posted (edited)

SOrry thx for yur time!😉 The lisp works good, but there are severals steps 2 do it, Like when i type MPOLYOUTLINEH, it ask me select object, i then select objects, then it ask me delete yes or no, and i click Yes, then it finish.

I would like to see the lisp that don't have do step bij step, but instant change it. I do apolgize for all my mistaken/request.

Edited by CAD
Posted (edited)

Try this:

(defun c:mpolyoutlineh (/ b e h i s)
  (if
    (setq s (ssget "_X" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
     (progn (repeat (setq i (sslength s))
	      ;; RJP mod to apply solid hatch to outlines
	      ;; Odd results if you have self intersecting plines
	      (foreach c (lm:polyoutline (setq e (ssname s (setq i (1- i)))))
		(setq b (vlax-ename->vla-object (cdr (assoc 330 (entget e)))))
		(cond ((setq h (vlax-invoke b 'addhatch achatchobject "SOLID" :vlax-true))
		       (vlax-invoke h 'appendouterloop (list (vlax-ename->vla-object c)))
		       (vla-evaluate h)
		       (vla-put-layer h (cdr (assoc 8 (entget e))))
		      )
		)
	      )
	      ;; If the layer is locked nothing will be deleted
	      (entdel e)
	    )
     )
  )
  (princ)
)

 

Edited by ronjonp
Posted

I think this is perfect 😀👍 ,with one command, job is done, tomorrow i will test it more, but i looks like it runs perfect sofar!!

Posted (edited)

I think the lisp works fine thanks alot!!!!  Ronjonp

Edited by CAD
Posted
1 minute ago, CAD said:

I think the lisp works fine thanks alot!!!!  Ronjonp

Glad to help, although you really should be thanking Lee since his code is the 'magic sauce' that even makes it possible. 😎

  • Thanks 1
Posted

You the best!! Lee lisp combine with you works perfect 😀

Posted
3 hours ago, ronjonp said:

Glad to help, although you really should be thanking Lee since his code is the 'magic sauce' that even makes it possible. 😎

 

Thanks Ron :beer:

  • Thanks 1
  • 3 years later...

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...