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

Counting from the start...

8 REPLIES 8
Reply
Message 1 of 9
brandzo
472 Views, 8 Replies

Counting from the start...

Hi people,

 

I have a lisp that draws variety of entities such as lines, arcs, hatches, points, blocks, text etc. How can I make one single block containing all of them, i.e. one block that has all items drawn since the lisp was invoked. Any help will be greatly appreciated.

 

Thanks,

 

Brandzo

8 REPLIES 8
Message 2 of 9
BlackBox_
in reply to: brandzo

If not adding geometry by vla-* methods, you'll first need to query ENTLAST, then add you geometry via Command calls, etc. and then collect all objects added since using ENTNEXT, then create your BlockTableRecord and add the entities.

 

Also, in case you need it, here's a link to an online ActiveX reference; see the various Add* Methods:

 

http://entercad.ru/acadauto.en/index.html?page=idh_block_object.htm

 

 

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 3 of 9
Kent1Cooper
in reply to: brandzo


@brandzo wrote:

.... 

I have a lisp that draws variety of entities such as lines, arcs, hatches, points, blocks, text etc. How can I make one single block containing all of them, i.e. one block that has all items drawn since the lisp was invoked. Any help will be greatly appreciated.

....


If the entities are drawn automatically within the Lisp routine, you can use (ssadd) after each one [which would be (entlast) immediately after] to put them all into a selection set.  If you call that ss, then after the last one is added:

 

(sssetfirst nil ss); makes them selected

(initdia); use the dialog box in following command

(command "_.block")

 

That should leave you in the Block Definition dialog box, with the object selection already done, where you can give it a name and specify an insertion point, and other options [e.g. whether to convert them to a Block in place, etc.].  If you want those aspects automated, too, that can be done, with a little direction about how you would want to determine the Block name and insertion point.

 

If you want the User to do the drawing, and of an indeterminate number of things, it's harder to picture how to do it with one Lisp routine, but I can imagine a way to do it with two commands, one to start the group of entities and another to close it and make a Block out of everything drawn since the first command.  Is that worth pursuing?

Kent Cooper, AIA
Message 4 of 9
brandzo
in reply to: brandzo

Thanks for the reply! I'm not familiar with ActiveX and VBA, just wanted to collect all entities drawn from the start of routine and make a single block at the very end of routine without entering ENTLAST at many places inside the code...

Message 5 of 9
hmsilva
in reply to: brandzo

Try

 

(command "Your first object")
(setq ss (ssadd))
(setq ob (entlast))
(ssadd ob ss)
(command "Your other objects")
(while (setq ob (entnext ob));;after you've created all objects
(ssadd ob ss) )

 Henriique

EESignature

Message 6 of 9
hgasty1001
in reply to: brandzo

Hi,

 

a simplistic approach could be:

 

1.- Select all entities and put it in a selection set (setq before (ssget "X"))

2.- Let the user do what he have to do 

3.-. Select all entities *minus* the original selection set (command "select" "all" "r" before "")

4.- Name the selection set (setq after (ssget "p"))

5.- Now you have a previous selection set with just the entities added by the user.

6.- Create the block

 

Sure there are other ways to do that, one is to keep track of each entity added by the user and add it to a selection set.

 

Gaston Nunez

 

 

Message 7 of 9
brandzo
in reply to: brandzo

Hi Kent, glad to have help from you. To be more precise, the routine inserts points from a point file and draws point markers, corresponding label next to point marker itself and place blocks at point locations. Sometimes, these blocks are exploded when inserted, depend of user choice. That means I have hundreds (sometime thousands) of various entities inserted in a drawing with more than one hundred of various layers. What I'm trying to achieve is to collect all of items and automatically make one single block.

To automated the whole process (as you ask), I'd go thru -BLOCK command and chose any block name and insertion point 0,0 and immediately call -INSERT command to insert that block. Any thoughs?

 

Thank you for help!

Message 8 of 9
brandzo
in reply to: brandzo

Thank you all guys, I'll try all of you suggestions...

Message 9 of 9
Hallex
in reply to: brandzo

Me think you have to try -WBLOCK command as well
See the Help file
_____________________________________
C6309D9E0751D165D0934D0621DFF27919

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

Post to forums  

Autodesk Design & Make Report

”Boost