Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Civil 3D, Select Objects by Object Data 1

Status
Not open for further replies.

ewbjr

Civil/Environmental
Oct 5, 2009
2
I have been going crazy trying to figure out how to do this. I would like a LISP routine, called "SELECTOD", which would select all items on the current layer that have a certain field value set in their Object Data. It would presumably need to prompt for the field name and value. Everything on the current layer that has this field name and value would then be selected. I could then do as I wish with it: delete it, move it to another layer, etc. I can't figure out how to tell the ssget command to use the current layer without specifying its name, and I can't figure out how to tell it the attribute name and value to filter by. Or should I be using something besides the ssget command? I would be grateful for the help, thanks!
 
Replies continue below

Recommended for you

You can get the current layer from the 'clayer' system variable.

An example to select everything on current layer;

(setq CurLayer(getvar "clayer"))
(setq ss (ssget "x" (list (cons 8 CurLayer))))

Not sure what you mean by object data, so this method might not necessarily be expanded to do what you want...

 
This does indeed select the current layer. Thank you very much. This leaves me with:

(Defun C:SELECTOD ()
(setq CurLayer(getvar "clayer"))
(setq ss (ssget "x" (list (cons 8 CurLayer))))
(sssetfirst nil ss)
(princ))

Now if only I could figure out how to filter this set according to the value of an object data field. Object data are custom properties that can be assigned to objects in Civil 3D, and perhaps other AutoCAD flavors also. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor