ahyin Posted July 26, 2011 Share Posted July 26, 2011 Dear All, Please help for correct my code, I want to select all polylines in layer1 and layer2 but got error message of bad function: -4.0, anything wrong with my code ? Thanks ! (setq total (ssget "x" (list '(0 . "lwpolyline") (-4. "<and") (cons 8 "layer1")(cons 8 "layer2") <-4. "and>")(cons 410 (getvar "ctab"))))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 26, 2011 Share Posted July 26, 2011 (setq total (ssget "x" (list '(0 . "lwpolyline") (cons 8 "layer1,layer2") (cons 410 (getvar "ctab")) ) ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
ketxu Posted July 26, 2011 Share Posted July 26, 2011 (edited) Your ") is wrong.Correct is (-4 . "and>") And i think you must use OR instead of AND ^^ One object can't be on two layer. Edited July 26, 2011 by ketxu Quote Link to comment Share on other sites More sharing options...
David Bethel Posted July 26, 2011 Share Posted July 26, 2011 Maybe: You need a space after the -4 (-4. should be (-4 . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 26, 2011 Share Posted July 26, 2011 There are two ways you can approach this, using the Logical Filter codes: (ssget "_X" (list '(0 . "LWPOLYLINE") '(-4 . "<OR") '(8 . "layer1") '(8 . "layer2") '(-4 . "OR>") (cons 410 (getvar "ctab")) ) ) Or using a Wildcard filter, such as: (ssget "_X" (list '(0 . "LWPOLYLINE") '(8 . "layer[12]") (cons 410 (getvar "ctab")) ) ) I would recommend you read all sections of the Visual LISP IDE Help Documentation under: AutoLISP Developers Guide > Using the AutoLISP Language > Using AutoLISP to Manipulate AutoCAD Objects > Selection Set Handling Also, have a read of this regarding use of the apostrophe to mark expressions as literal. Quote Link to comment Share on other sites More sharing options...
ahyin Posted July 27, 2011 Author Share Posted July 27, 2011 Thank you much all of your help ! Quote Link to comment Share on other sites More sharing options...
ahyin Posted July 27, 2011 Author Share Posted July 27, 2011 Dear Lee Mac, If I use the function vlax-get-property to get the layer name and make the selection set the below code correct or not ? ](ssget "_X" (list '(0 . "LWPOLYLINE") '(-4 . "<OR") '(8 . (vlax-get-property object1 'Name)) '(8 . (vlax-get-property object2 'Name)) '(-4 . "OR>") (cons 410 (getvar "ctab")) ) ) There are two ways you can approach this, using the Logical Filter codes: (ssget "_X" (list '(0 . "LWPOLYLINE") '(-4 . "<OR") '(8 . "layer1") '(8 . "layer2") '(-4 . "OR>") (cons 410 (getvar "ctab")) ) ) Or using a Wildcard filter, such as: (ssget "_X" (list '(0 . "LWPOLYLINE") '(8 . "layer[12]") (cons 410 (getvar "ctab")) ) ) I would recommend you read all sections of the Visual LISP IDE Help Documentation under: AutoLISP Developers Guide > Using the AutoLISP Language > Using AutoLISP to Manipulate AutoCAD Objects > Selection Set Handling Also, have a read of this regarding use of the apostrophe to mark expressions as literal. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 27, 2011 Share Posted July 27, 2011 (edited) If I use the function vlax-get-property to get the layer name and make the selection set the below code correct or not ? IMO - Someone didn't listen to good advice : I would recommend you read all sections of the Visual LISP IDE Help Documentation under: AutoLISP Developers Guide > Using the AutoLISP Language > Using AutoLISP to Manipulate AutoCAD Objects > Selection Set Handling Also, have a read of this regarding use of the apostrophe to mark expressions as literal. ... In any event, use cons when evaluating an expression: (ssget "_X" (list '(0 . "LWPOLYLINE") '(-4 . "<OR") [color="red"]([/color][color="blue"]cons [/color]8 (vlax-get-property object1 'Layer)[color="red"])[/color] [color="red"]([/color][color="blue"]cons[/color] 8 (vlax-get-property object2 'Layer)[color="red"])[/color] '(-4 . "OR>") (cons 410 (getvar "ctab")) ) ) HTH Edited July 27, 2011 by BlackBox Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 27, 2011 Share Posted July 27, 2011 Could a LWpolyline have a property of name or a layer name ? And how to filter for Layer name ( vlax-get-property.....before with the variable holds the selection set of objects to get the layer name of them ? Am I right or misunderstood the idea ? Thanks Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 27, 2011 Share Posted July 27, 2011 Could a LWpolyline have a property of name or a layer name ? I *believe* an Entity Object has a "Layer" property, whereas a Layer Object has a "Name" property. And how to filter for Layer name ( vlax-get-property.....before with the variable holds the selection set of objects to get the layer name of them ? Am I right or misunderstood the idea ? Honestly, I too would need more information to answer this with regard to the OP's intention. However, here's one way to feed an ssget filter object information: (vl-load-com) (if (and (setq e (car (entsel "\nPick any object on the desired layer: "))) (setq v (vlax-ename->vla-object e))) (progn (ssget "_X" (list '(0 . "LWPOLYLINE") (cons 8 (vlax-get-property v 'Layer)) (cons 410 (getvar "ctab")))) ;; ... More code ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 27, 2011 Share Posted July 27, 2011 Exactly it is Layer . That's what I wanted to indicate to . many thanks. Quote Link to comment Share on other sites More sharing options...
ahyin Posted July 28, 2011 Author Share Posted July 28, 2011 Thousand thanks for all of you ! I will take a look the help first in next time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.