AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Member
melapier
Posts: 3
Registered: ‎09-01-2011
Message 1 of 5 (178 Views)

subtract two blocks from eachother

178 Views, 4 Replies
09-01-2011 12:31 AM

Hello everyone

First of all I really don’t have a clue about lisp and jet I should work with it, so problems are foreseen.

To my problem:

 

I have two blocks and I would like to subtract them, so that I get a howl in the first block.

I have tried it with _subtract but that didn’t work. AutoCAD always tells me that it didn’t know the two components.

I tried it with:

 

(Command "_subtract" "Block1" "block2" "")

 

I know that it’s wrong but can someone help me out here before I bite in my Keyboard?

Distinguished Mentor
skintsubby
Posts: 549
Registered: ‎09-29-2004
Message 2 of 5 (177 Views)

Re: subtract two blocks from eachother

09-01-2011 12:42 AM in reply to: melapier

Are you sure you mean blocks? Not solids?

 

if it's solids then this lisp is cheap and nasty, with no error handler but should do what you want.

 

(defun c:sub (/ obj1 obj2)
(setq echo (getvar "cmdecho"))
(setvar "cmdecho" 0)
(princ "\nSelect solids and regions to subtract from..")
(setq obj1 (ssget))
(princ "\nSelect solids and regions to subtract..")
(setq obj2 (ssget))
(command "copy" obj2 "" "0,0" "0,0")
(command "subtract" obj1 "" obj2 "")
(setvar "cmdecho" echo)
(princ)
)  

 

If it is blocks are they solids? can you provide more details of these blocks?

Member
melapier
Posts: 3
Registered: ‎09-01-2011
Message 3 of 5 (175 Views)

Re: subtract two blocks from eachother

09-01-2011 12:57 AM in reply to: skintsubby

They are really Blocks

 

( defun Block1 ()

 

  ( EINBLK "BK-FQuader" ( list -240.0   0.0      0.0 )  480.0  440.0 9720.0  0.0 )

 

)

 

(defun Block2()

 

  ( EINBLK "BK-FQuader" ( list -110.0   0.0    170.0 )  220.0  445.0  160.0  0.0 )

  ( EINBLK "BK-FQuader" ( list -110.0   0.0    490.0 )  220.0  445.0  160.0  0.0 )

  ( EINBLK "BK-FQuader" ( list -110.0   0.0    810.0 )  220.0  445.0  160.0  0.0 )

)

And jet I want to subtract the second block from the first

Distinguished Mentor
skintsubby
Posts: 549
Registered: ‎09-29-2004
Message 4 of 5 (170 Views)

Re: subtract two blocks from eachother

09-01-2011 01:10 AM in reply to: melapier

What is EINBLK? Perhaps it should be ENDBLK? You'll have to post all your code..

Member
melapier
Posts: 3
Registered: ‎09-01-2011
Message 5 of 5 (163 Views)

Re: subtract two blocks from eachother

09-01-2011 01:25 AM in reply to: skintsubby

 

 ( defun EINBLK ( hName hP hX hY hZ hInsWin )  

 ( command "_INSERT" hName hP "_XYZ" hX hY hZ hInsWin )
)

 

 

( defun Block1 ()

  ( EINBLK "BK-FQuader" ( list -240.0   0.0      0.0 )  480.0  440.0 9720.0  0.0 ) 

)

 

(defun Block2()

  ( EINBLK "BK-FQuader" ( list -110.0   0.0    170.0 )  220.0  445.0  160.0  0.0 )

  ( EINBLK "BK-FQuader" ( list -110.0   0.0    490.0 )  220.0  445.0  160.0  0.0 )

  ( EINBLK "BK-FQuader" ( list -110.0   0.0    810.0 )  220.0  445.0  160.0  0.0 )

)

( defun const ()

  ( setq dwgT10 "D:/ test/bas/T10/Zeichnungen/" )

 

( defun SAE ()

(const)

  ( EINBLK ( strcat dwgML10 "Block1" ) ( list  0.0  0.0  0.0 )  1.0 1.0 1.0  0.0 )

  ( EINBLK ( strcat dwgML10 "Block2" ) ( list  0.0  0.0  0.0 )  1.0 1.0 1.0  0.0 )

  ( command "_subtract" "" "Block1"  "Block2" )

)

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.