Jump to content

Lisp convert several polyline with width to hatch solid?


CAD

Recommended Posts

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?

Link to comment
Share on other sites

(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)
)

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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