Jump to content

Solid to hatch solid


KJB

Recommended Posts

Earlier I googled "SOLID TO HATCH" and came across a LSP on different forum.

I thought I give this site before I got too involved with LISP.

Link to comment
Share on other sites

Piece of cake. Here are the two LSP files required to convert a SOLID to a hatch "solid". No modification was required on my part.

 

LISP routine from Jeff Mishler found on CADForums.net

 

(defun get_space ()

(if (= (getvar "cvport") 1)

(vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object)))

(vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))

)

)

 

(defun convert2dsolids (/ 2dcoords coords count hatch obj pline space ss)

(and (setq ss (ssget '((0 . "SOLID"))))

(setq count -1)

(setq space (get_space))

(while (

(setq obj (vlax-ename->vla-object (ssname ss count)))

(setq coords (vlax-get obj 'coordinates))

(setq 2dcoords (list (car coords)(cadr coords)))

(setq coords (cdr (cdr (cdr coords))))

(setq 2dcoords (append 2dcoords (list (car coords)(cadr coords))))

(setq coords (cdr (reverse (cdr (cdr (cdr coords))))))

(setq 2dcoords (append 2dcoords (list (cadr coords)(car coords))))

(setq coords (reverse coords))

(setq 2dcoords (append 2dcoords (list (car coords)(cadr coords))))

(setq pline (vlax-invoke space 'addlightweightpolyline 2dcoords))

(vla-put-closed pline :vlax-true)

(setq hatch (vlax-invoke space 'addhatch acHatchPatternTypePredefined

"SOLID" :vlax-true))

(vlax-invoke hatch 'appendouterloop (list pline))

(vla-put-color pline (vla-get-color obj))

(vla-put-color hatch (vla-get-color obj))

(vla-put-layer pline (vla-get-layer obj))

(vla-put-layer hatch (vla-get-layer obj))

(vla-delete obj)

)

)

)

(defun c:cd ()

(convert2dsolids)

(princ)

)

Edited by KJB
Link to comment
Share on other sites

So you asked the question already knowing not only what the answer would be but how to solve the puzzle too?

 

You are one devious bassturd. No offense meant. LOL

Link to comment
Share on other sites

Like I said before I was intimidated by the posts of the other forum and instead of just copy the lisps file and see what happens.

I started a post here because I have a lot more respect for you guys.

Link to comment
Share on other sites

Ok, so who wrote the lisp routine that you posted? Did you write it? If so, then you should add a header with your name and info.

If someone else wrote it, then you should give credit to the author.

Link to comment
Share on other sites

Thank you for your lisp! It 's very useful!!!

Although in this case the solid is not converted "spontaneously" ... is kicked and it says "becomes a hatch!"

I do not know very well the language lisp, but this really seems to me the time of its shooting. Perhaps because it has resisted ...

...

(vla-delete obj)

...

 

Hi,

Marco:):):)

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