TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on May 19, 2015, 04:14:33 PM

Title: Place Block inside mulitple Blocks?
Post by: MSTG007 on May 19, 2015, 04:14:33 PM
Is it possible to have a routine that can take a Block (Block 1) and place (Block 1 @0,0) inside a selection of blocks that are not shown in the drawing but the definition is at the same insertion point? I have one block that I need to place into 40 + Blocks. The Scales of the blocks are 1:1, its just getting them in there. I figured I would ask before starting it. Thanks guys!
Title: Re: Place Block inside mulitple Blocks?
Post by: danallen on May 19, 2015, 04:32:19 PM
Why not redefine the block that is inserted 40+ times (call it block 0)? Or do you have say 80 inserts of block 0 and need to add block 1 at only 40 of them?

If the latter, copy the 40, paste into blank drawing. Rename block definition from block 0 to block 1, copy/paste back into original drawing using same origin. Voila!
Title: Re: Place Block inside mulitple Blocks?
Post by: MSTG007 on May 19, 2015, 04:34:18 PM
I have a bunch of casting circle blocks. I am trying get an inlet protection block in all of those casting blocks. Does that make any sense?
Title: Re: Place Block inside mulitple Blocks?
Post by: danallen on May 19, 2015, 04:38:43 PM
Sounds like civil stuff, I'm an architect, so not much. But doesn't change my suggestions
Title: Re: Place Block inside mulitple Blocks?
Post by: roy_043 on May 20, 2015, 04:13:52 AM
Perhaps something like this:
Code - Auto/Visual Lisp: [Select]
  1. (setvar 'clayer "0")
  2. (foreach blockDefName blockDefNameList
  3.   (if (tblobjname "block" blockDefName) ; Add check for xref if required.
  4.       (vla-item blocksObject blockDefName)
  5.       'insertblock
  6.       '(0.0 0.0 0.0)
  7.       blockName
  8.       1.0 ; X-scale.
  9.       1.0 ; Y-scale.
  10.       1.0 ; Z-scale.
  11.       0.0 ; Angle.
  12.     )
  13.   )
  14. )
Title: Re: Place Block inside mulitple Blocks?
Post by: MSTG007 on May 20, 2015, 07:30:37 AM
Thank you for sharing this, Could I ask how to execute the command please?
Title: Re: Place Block inside mulitple Blocks?
Post by: roy_043 on May 20, 2015, 08:35:39 AM
Thank you for sharing this, Could I ask how to execute the command please?
The supplied code is not a complete (command) function. You will have incorporate the code snippet is your own function.
Title: Re: Place Block inside mulitple Blocks?
Post by: dgorsman on May 20, 2015, 10:18:45 AM
Bascially, yes - it is possible.  You manipulate the block definition (add the second block as an insert) rather than model or paper space.