Hopefully this is a quick one...I am using autocad electrical 2011, i am writing a program that inserts certain components based on information on the drawing. I insert a wblocked "circuit" using this command (insertionpoint should be obvious)
(c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/LEVEL generic_2-wire.dwg" insertionpoint 1.0 😎
This will insert a couple of blocks, wires & cable markers. Is there a way to create a selection set of the items inserted this way?
Thanks
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
(setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 "blocknames,seperated,by,commas"))))
@gcsjlewis wrote:
(c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/LEVEL generic_2-wire.dwg" insertionpoint 1.0 😎
This will insert a couple of blocks, wires & cable markers. Is there a way to create a selection set of the items inserted this way?
Something like this perhaps
(setq ss (ssadd)) (setq ob (entlast)) (c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/LEVEL generic_2-wire.dwg" insertionpoint 1.0 8) (while (setq ob (entnext ob)) (ssadd ob ss) )
HTH
Henrique
@gcsjlewis wrote:
This seems to be creating a selection set of everything on the drawing, not just the previously inserted items:
Currently using what you have (sslength ss) should return a count of 22 items(I only want one of these items)
But it returns 135. Which is everything on my drawing
Should return only the new entities...
(setq ss (ssadd));; creates a new selection set (setq ob (entlast));; the name of the last entity in the drawing (c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/LEVEL generic_2-wire.dwg" insertionpoint 1.0 8) (while (setq ob (entnext ob));;add all entities next to (setq ob (entlast)) (ssadd ob ss) )
"I only want one of these items"
before add to ss, test for the item you want.
HTH
Henrique
If that command definition is yours, re-build it to pull out the insertion routine so it returns the inserted entities. Then you can just use the command defun as a wrapper to pass arguments.
If that *isn't* your command defintion you need to go the long way around: select everything in the drawing, run the function, then select everything *again* and remove everything from the pre-function selection set.
@dgorsman the "c:wd_ins_circ2" function is from the AutoCAD Electrical API
(setq ss (ssadd)) (setq ob (entlast)) (c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/LEVEL generic_2-wire.dwg" insertionpoint 1.0 8) (while (setq ob (entnext ob)) (if (and (= (cdr (assoc 0 (entget ob))) "INSERT") (wcmatch (cdr (assoc 2 (entget ob))) "MyBlk1,MyBlk2,MyBlk3") ) (ssadd ob ss) ) )
should work...
HTH
Henrique