Blocks & Scripts

Blocks & Scripts

FeeopEngr
Advocate Advocate
752 Views
3 Replies
Message 1 of 4

Blocks & Scripts

FeeopEngr
Advocate
Advocate

AC Lt 17 win 64

 

I have a drawing with multiple instances of block A (a circle with insertion point at the center). I want to add block B (a square with insertion point at center) on top of each block A, matching the insertion points (keep both blocks).

 

Is this possible using scripts?

Feeop
0 Likes
753 Views
3 Replies
Replies (3)
Message 2 of 4

CodeDing
Advisor
Advisor

Feeop,

 

Is this what you might be looking for? Hope this helps

 

~DD

 

(defun TwoBlocks (/ insPt)

(setq insPt (getpoint "\nSelect insertion point: "))
(command "_insert" "BlockA" insPt "1" "" "")
(command "_insert" "BlockB" insPt "1" "" "")

(princ)

);defun
0 Likes
Message 3 of 4

CodeDing
Advisor
Advisor

Feeop,

 

On re-reading your question, this might be more what you're looking for..

Assistance from >>>HERE<<<

 

Best,

~DD

 

(defun c:MOREBLOCKS (/ insPt)

(setq insPt (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "YourBlockName"))) 0)))))
(command "_insert" "BlockB" insPt "1" "" "")

(princ) );defun
0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

@FeeopEngr wrote:

AC Lt 17 win 64

 

I have a drawing with multiple instances of block A (a circle with insertion point at the center). I want to add block B (a square with insertion point at center) on top of each block A, matching the insertion points (keep both blocks).

 

Is this possible using scripts?


Unfortunately, that precludes the use of an AutoLisp routine.  I don't know of a way in a Script or command macro to find all insertions of a certain Block name and dig out their insertion points for Inserts of another Block.

 

A workaround could be to edit the definition of Block A by adding an insertion of Block B to it.  But then if you need to Explode all the Block A's to "free" the Block B's if they need to be independent, the pieces that make up Block A's original definition would then be "loose" and not part of a Block any more.  If the Circle is the only thing in the Block definition, maybe that would be acceptable.

Kent Cooper, AIA
0 Likes