AutoCAD 2010/2011/2012

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

subtract two blocks from eachother

163 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: 542
Registered: ‎09-29-2004
Message 2 of 5 (162 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 (160 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: 542
Registered: ‎09-29-2004
Message 4 of 5 (155 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 (148 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" )

)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community




Connect with AutoCAD

Twitter

Facebook

Blogs

Pinterest

Youtube