Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

creating a selection set of items inserted using API command

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
gcsjlewis
468 Views, 7 Replies

creating a selection set of items inserted using API command

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

7 REPLIES 7
Message 2 of 8
bhull1985
in reply to: gcsjlewis

(setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 "blocknames,seperated,by,commas"))))

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 3 of 8
hmsilva
in reply to: gcsjlewis


@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

EESignature

Message 4 of 8
gcsjlewis
in reply to: bhull1985

I'd like to not do that, because as my program runs, blocks will be constantly added. I'll give you a little more of my code:

((and (= (strcase (nth 1 input) nil) "4-20MA")(wcmatch plc01 "FT*")
(setq insertionpoint (list 18.5 (+ 0.5 (eval (read addressinsert)))))
(c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/flow generic_2-wire.dwg" insertionpoint 1.0 😎
**if this is true and the wblock is inserted I want to grab just the one block from the wblock and do things to it
))
((and (= (strcase (nth 1 input) nil) "LOOP")(wcmatch plc01 "FT*")
(setq insertionpoint (list 18.5 (+ 1.0 (eval (read addressinsert)))))
(c:wd_ins_circ2 "T:/acad/schematic_circuits/transmitters/flow generic_2-wire.dwg" insertionpoint 1.0 😎
**if this is true and the wblock is inserted, I want to grab just the one block from the wblock and do other things to it
))

.....this repeats a bunch of times

When all is said and done, I will have inserted up to 16 wblocks. I could create a selection set afterwards of the 16 items I need based on block name, but then I would have to get a bunch of information that I already grabbed to insert them to begin with. I just wasn't sure if there was a way to create a selection set (using entlast or something) to grab the last block inserted with a specified name.

I believe your way, if I did it, after the first block it would work, but after the second wblock is inserted, if I create a selection set it would include one that I already inserted

Hope this makes sense.


________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 5 of 8
gcsjlewis
in reply to: hmsilva

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

________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 6 of 8
hmsilva
in reply to: gcsjlewis


@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

 

EESignature

Message 7 of 8
dgorsman
in reply to: gcsjlewis

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 8 of 8
hmsilva
in reply to: hmsilva

@dgorsman the "c:wd_ins_circ2" function is from the AutoCAD Electrical API

 

@gcsjlewis 

 

(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

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost