Jump to content

Quick Selection Lisp


nicolas

Recommended Posts

Hi,

 

I want to automate the quick select process by having a lisp that can delete all blocks in a drawing except those containing string "column," "beam" as block|name. I can't use quick select in autolisp. There is no command line equivalent. I learned about ssx and filter but I really don't know how to use them effectively.

 

Regards,

 

Nicolas.

Link to comment
Share on other sites

Hi nicolas,

 

Use the ssget function:

 

(ssget "_X" '((0 . "INSERT") (2 . "column,beam")))

 

And to highlight the set:

 

(sssetfirst nil (ssget "_X" '((0 . "INSERT") (2 . "column,beam"))))

Link to comment
Share on other sites

Thank you Lee Mac for the codes. However due to having but little knowledge of autolisp, I am still in darkness as to how to apply the codes You have send. I do understand that ssget have to do with selection that is going to be recorded in a variable. Is such variable called _X or am i totally lost here? What is sssetfirst? Some tips are greatly needed. Thank you very much in advance.

Link to comment
Share on other sites

I do understand that ssget have to do with selection that is going to be recorded in a variable. Is such variable called _X or am i totally lost here?

 

The "_X" mode string will instruct the ssget function to search the whole database when acquiring a SelectionSet. In this respect I would suggest that you read the help documentation on the ssget function, this short tutorial will show you how.

 

What is sssetfirst?

 

sssetfirst will highlight a SelectionSet (turn on the grips) - again, if unsure about a function, just type it in the Visual LISP IDE and open the help for that function. A short introductory lesson on the Visual LISP IDE can be found here.

 

As for how to apply the code, after re-reading your post, I notice you want to delete all blocks which are not called either column or beam, so the following function will demonstrate how to highlight a SelectionSet of all blocks which are not callled either column or beam:

 

(defun c:test nil
 (sssetfirst nil (ssget "_X" '((0 . "INSERT") (-4 . "<NOT") (2 . "column,beam") (-4 . "NOT>"))))
 (princ)
)

 

A reference for the DXF codes used in the SelectionSet filter can be found here.

 

Following selection you can delete them using the erase command. A LISP could also perform the deletion, but I felt it was safer to let the user hit the delete key. :wink:

Link to comment
Share on other sites

Hi Lee Mac,

 

Thank you for the code. However, when applying it to the drawing, it select everything. The two layers containing beams and columns that I want to filter out is : 1A_2_Columns, beam. I also note that the file start likewise:

(defun c:test nil

 

should i insert a variable name in the place or use the slash + space when defining local variable

 

Meanwhile im digging the help files on sssget. Many thanks.

 

Regards,

 

Nicolas

Edited by nicolas
additional data
Link to comment
Share on other sites

This will select all blocks except those on the layers you specified:

 

(defun c:test nil
 (sssetfirst nil (ssget "_X" '((0 . "INSERT") (-4 . "<NOT") (8 . "1A_2_Columns,beam") (-4 . "NOT>"))))
 (princ)
)

 

The space after 'test' would contain the local variables, but the above code has no local variables, so this can be nil.

 

Lee

Link to comment
Share on other sites

Nothing wrong with what Lee posted, but knowing how to use SSX and QSelect will be much more valuable.

 

SSX eg.

Command: ssx

Select object <None>:

Enter filter option [block 
name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector]: E

>>Enter entity type to add <RETURN to remove>: INSERT

Current filter: ((0 . "INSERT"))
Enter filter option [block 
name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector]: B

>>Enter block name to add <RETURN to remove>: ~BEAM

Current filter: ((2 . "~BEAM") (0 . "INSERT"))
Enter filter option [block 
name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector]:

Will Select all blocks (insert) that do not match the block name "BEAM" (the "~" ignores such text, whereas if I had put "DOG" it would have selected all blocks with name of "DOG"). Also note that except for the 1 code (text/attribute strings), dxf codes are not case sensitive.

Link to comment
Share on other sites

  • 2 weeks later...

Hi Lee Mac,

 

I try the program anew. The problem was that the content of the beams were actually in beam layer but the outer entity was on layer 0. I correct both contents and overall block to beam layer and that little program is indeed working. Hence the (8 . "1A_2_Columns,beam")

 

Hence I do understand that we can extend and add wildcards to

the deselect list.

 

For Example:

 

(8. "*?olumns*,*?eam*,*walls*)

 

So that having Column 200, column, Column, Column 200x200 or beam,

Beam 200 ... all will work.

 

 

Thanks again,

 

Regards,

 

Nicolas.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...