The command to insert a block through the command line

The command to insert a block through the command line

AlexBern44
Advocate Advocate
1,085 Views
3 Replies
Message 1 of 4

The command to insert a block through the command line

AlexBern44
Advocate
Advocate

I would like to upgrade the existing code for inserting blocks into a drawing via the command line.

This code is for inserting a block from the folder in which it is permanently stored.

My goal is that immediately after insertion, this block will explode into elements

.

An example of the original code:

(command "_.insert" "C:\Users\\User\\\Documents\\\Library\\Gates and fences\Fence 2" pause "" "" "")

 

Is it possible to make code that included both of these commands: insertion and explode in one line?


Thanks,
Alex

0 Likes
Accepted solutions (1)
1,086 Views
3 Replies
Replies (3)
Message 2 of 4

CraigP_
Enthusiast
Enthusiast

If I am not mistaken adding an asterisk (*) at the start of the filename will explode the block on insert.

 

(command "_.insert" "*C:\Users\\User\\\Documents\\\Library\\Gates and fences\Fence 2" pause "" "" "")

Craig
Message 3 of 4

pbejse
Mentor
Mentor
Accepted solution

@AlexBern44 wrote:

Is it possible to make code that included both of these commands: insertion and explode in one line?

 


 

(command "_.insert" "C:\\Users\\User\\Documents\\Library\\Gates and fences\\Fence 2.dwg"
	 pause "" "" "" "_explode" (entlast))

 

or adding "*" at the filename, but you wont see a preview when inserting the block

 

(command "_.insert" "*C:\\Users\\User\\Documents\\Library\\Gates and fences\\Fence 2.dwg" pause "" "" "")

 

Keep in mind that using the call to command "insert" pose some issues with the way the block is created

  • Scale uniformly
  • Attributes in blocks
  • Attributes setting , Attreq/Attdia..
  • Allow exploding* [ another can of worms ]

Others do it this way to deal with the issues on top of setting the system variables

 

(command "_.insert"
  "C:\\Users\\User\\Documents\\Library\\Gates and fences\\Fence 2.dwg" pause
)
(while (> (getvar "CMDACTIVE") 0)
  (command "")
)
(command "_explode" (entlast));<-- sometimes BURST for attributes with default value

 

So one line may not always work.

 

In your case where the block is known, you can force the settings and a one liner may work as expected,

HTH

 

Message 4 of 4

AlexBern44
Advocate
Advocate

 

I thank you for this informative and helpful answer. This is exactly the code I was thinking about🌞

0 Likes