Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

convert solid to hatch

25 REPLIES 25
Reply
Message 1 of 26
Anonymous
26891 Views, 25 Replies

convert solid to hatch

is there a way to convert multiple 2d solids to bhatches. i have searched the discussion groups and have not seen anything. any help much appreciated
25 REPLIES 25
Message 2 of 26
Anonymous
in reply to: Anonymous

Here's a little routine for ya. (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 count (1+ count)) (sslength ss)) (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) ) -- Jeff check out www.cadvault.com "jimsmart" wrote in message news:19395869.1105051565593.JavaMail.jive@jiveforum2.autodesk.com... > is there a way to convert multiple 2d solids to bhatches. i have searched > the discussion groups and have not seen anything. any help much > appreciated
Message 3 of 26
Anonymous
in reply to: Anonymous

thanks jeff for your trouble, i tried the routine, and it returned ,; error: no function definition: GET_SPACE, my knowledge of lisp is very basic, do you know how to fix this error.

james
Message 4 of 26
Anonymous
in reply to: Anonymous

Oops, my apologies. Load this prior to running the other. (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))) ) ) -- Jeff check out www.cadvault.com "jimsmart" wrote in message news:11004369.1106265122464.JavaMail.jive@jiveforum1.autodesk.com... > thanks jeff for your trouble, i tried the routine, and it returned ,; > error: no function definition: GET_SPACE, my knowledge of lisp is very > basic, do you know how to fix this error. > > james
Tags (2)
Message 5 of 26
Anonymous
in reply to: Anonymous

thankyou jeff that works great, will save our office a lot of time
Message 6 of 26
Anonymous
in reply to: Anonymous

Mr. Mishler:

The original poster had success with this routine, but he knows something I do not, obviously: How do I start the routine? What do I type in at the command line to fire the thing off? I've loaded it successfully, but what now?

It may be obvious to you, but many people are not programmers, and need basic documentation.
Message 7 of 26
JamaL9722060
in reply to: Anonymous

Hi Mishler,

 

I’m looking for similar lisp that changes solid (objects created by Solid command) to solid hatch (created by hatch command) but unfortunately couldn’t integrate you have share in post #2 and post #4

 

Sorry I have poor coding skills.

 

May you please stick these two bunches of code in one lisp file?

 

Thank you

 

Best

 

Jamal

---------------------------
Jamal Numan
Message 8 of 26
hmsilva
in reply to: JamaL9722060

Jamal,

 attached is Jeff Mishler's lisp...

 

hope that helps

Henrique

EESignature

Message 9 of 26
JamaL9722060
in reply to: hmsilva

Many thanks Henrique for the answer,

 

Sounds that this lisp file creates also a boundary for the hatch (attached). In may case, there is no need to create boundary for the hatch.

 

How might this lisp be customized to convert the solid to hatch ONLY (without boundary)?

 

Best

 

Jamal

---------------------------
Jamal Numan
Message 10 of 26
hmsilva
in reply to: JamaL9722060

You're welcome, Jamal

 

"How might this lisp be customized to convert the solid to hatch ONLY (without boundary)?"

 

the easy way...

after

(vla-delete obj)

add

(vla-delete pline)

 

hope that helps

Henrique

EESignature

Message 11 of 26
JamaL9722060
in reply to: hmsilva

 

Perfect! It works fine

 

Very much appreciated Henrique

 

Best

 

Jamal

---------------------------
Jamal Numan
Message 12 of 26
hmsilva
in reply to: JamaL9722060

You're welcome, Jamal
glad i could help

Henrique

EESignature

Message 13 of 26
Anonymous
in reply to: hmsilva

Hi,

 

I tried the LISP routine, I got the message that it loaded successfully but I can't start it (After loading I entered "get_space" and "convert2dsolids" but I get the message "Unknown command".)

 

What am I doing wrong?

 

 

Message 14 of 26
hmsilva
in reply to: Anonymous


@Anonymous wrote:

Hi,

 

I tried the LISP routine, I got the message that it loaded successfully but I can't start it (After loading I entered "get_space" and "convert2dsolids" but I get the message "Unknown command".)

 

What am I doing wrong?

 

 


Hi stblb,

after loaded, type cd or (convert2dsolids)

 

Hope this helps,
Henrique

EESignature

Message 15 of 26
quinnahenning
in reply to: hmsilva

Hi there,

 

Is there a way to incorporate this LISP into a command? Or an easier way to load the LISP file each time?

 

I had to use the LISP a couple of times, but I had to load it each time. Would think there is an easier way.

 

Thanks

Message 16 of 26
hmsilva
in reply to: quinnahenning


@quinnahenning wrote:

Hi there,

Is there a way to incorporate this LISP into a command? Or an easier way to load the LISP file each time?

I had to use the LISP a couple of times, but I had to load it each time. Would think there is an easier way.

Thanks


Hello quinnahenning and welcome to the Autodesk Community!

 

You may add the .lsp file to your 'Startup Suit' (command 'appload') and the the file will be loaded in all dwg's...

 

Hope this helps,
Henrique

 

EESignature

Message 17 of 26
c_frankkellogg
in reply to: hmsilva

Henrique,

 

Thanks for the lisp routine.

It did just what i was looking for.

 

I have added the code to my extensive acaddoc file, so it loads every time.

 

Only thing I changed was the "cd" to "c2s".

Not sure why it is called "convert2solids", when it is converting FROM solids.

 

No worries, it works!

 

CFK

Message 18 of 26
hmsilva
in reply to: c_frankkellogg


@c_frankkellogg wrote:

Henrique,

 

Thanks for the lisp routine.

It did just what i was looking for.

 

I have added the code to my extensive acaddoc file, so it loads every time.

 

Only thing I changed was the "cd" to "c2s".

Not sure why it is called "convert2solids", when it is converting FROM solids.

 

No worries, it works!

 

CFK


You're welcome, CFK
But all credits belong to Jeff Mishler, he is the 'convert2solids' author...

Henrique

EESignature

Message 19 of 26
Anonymous
in reply to: hmsilva

After I use convert2solids I'm getting

VLAX-GET-ACAD-OBJECT

What should I do?

Thanks a lot

Message 20 of 26
Anonymous
in reply to: hmsilva

Hello good afternoon someone could send me the routine pleace my email is leo_arq7@hotmail.com greetings from jalisco mexico

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost