Wblock a selection set

Wblock a selection set

Anonymous
Not applicable
3,266 Views
6 Replies
Message 1 of 7

Wblock a selection set

Anonymous
Not applicable

I have a selection set (SS1) and I want to wblock that selection set and name the block file a variable (PanelNumber) that was retrieved via lisp. 

0 Likes
Accepted solutions (1)
3,267 Views
6 Replies
Replies (6)
Message 2 of 7

Ranjit_Singh
Advisor
Advisor

Something like follows works for a sample block on my system.

(sssetfirst () ss1)
(command "._-wblock" path_var '(0 0 0))

You will need to provide the full path (including block name) for the block location (example "G:\\projects\\blocks\\my_block.dwg") to variable path_var 

 

0 Likes
Message 3 of 7

john.uhden
Mentor
Mentor

BTW, I don't think that sssetfirst has really required two (2) arguments for a long time (many releases).

I think that just (sssetfirst ss1) will do.

And to clear it, just (sssetfirst) works without any arguments.

John F. Uhden

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

I have a selection set (SS1) and I want to wblock that selection set and name the block file a variable (PanelNumber) that was retrieved via lisp. 


On the assumption that PanelNumber is an integer, and needs to be converted to text to make it the drawing name, try this:

 

(command

  "_.wblock" (strcat "X:\\Your\\File\\Path\\" (itoa PanelNumber)) "" YourInsertionBasePoint SS1 ""

  "_.oops"

)

 

If PanelNumber is a real number rather than an integer, use (rtos) instead of (itoa), and add mode and precision arguments.  If it's already text, omit the (itoa) wrapper altogether.

 

That may vary somewhat by version.  The first "" in there is to accept the <define new drawing> option in Acad2016 that I have here, but I don't think that's the way it has always worked.

 

Note that with the command-line  version of WBLOCK, the objects are always removed from the drawing [not a choice as in the dialog-box version], hence the OOPS command to bring them back.  Using "_.u" instead would also do it.

Kent Cooper, AIA
Message 5 of 7

Anonymous
Not applicable

Everything is working as desired (THANK YOU), but I am having issues with "YourInsertionBasePoint" part.  I have a previously set variable "scalecntrpt", but when I try and use this, it isnt working.

 

Here is the line I have...

(command "wblock" newblockpath "" scalecntrpt sss2 "")

 

"newblockpath" = c:\\My\File\Path

"ss2" = the selection set of items i am wblocking.

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Everything is working as desired (THANK YOU), but I am having issues with "YourInsertionBasePoint" part.  I have a previously set variable "scalecntrpt", but when I try and use this, it isnt working.

 

Here is the line I have...

(command "wblock" newblockpath "" scalecntrpt sss2 "")

 

"newblockpath" = c:\\My\File\Path

"ss2" = the selection set of items i am wblocking.


Does "newblockpath" include a file name for the drawing, in addition to the path part?

 

If you type !scalecntrpt [with the preceding exclamation point], what does it return?  It should be XY or XYZ coordinates enclosed as a list in parentheses.

 

You have sss2 in your code line [as quoted], but only ss2 in your description.  Does the actual code agree with the actual variable name?

 

What happens instead of what you want?  Are there any messages?  Etc.

Kent Cooper, AIA
0 Likes
Message 7 of 7

john.uhden
Mentor
Mentor

"newblockpath" = c:\\My\File\Path

A single backslash in the path won't do.  Use either a double backslash or a single foreslash.

 

"ss2" = the selection set of items i am wblocking.

Make up your mind between ss2 and sss2.

 

You might also consider using the EXPORT command.

John F. Uhden

0 Likes