Cycle through a list of block references at insertion

Cycle through a list of block references at insertion

Anonymous
Not applicable
2,043 Views
16 Replies
Message 1 of 17

Cycle through a list of block references at insertion

Anonymous
Not applicable

Hello all,

 

I was wondering if it's possible to enter a block that as long as the insertion point hasn't yet been selected - i.e we can still move the block around - allows us to cycle through a list of blocks of our own to choose the most suited for the situation. Someone could argue that why not using visibility states? Well each block is really complex.

 

Would it be possible?

Would it also be possible to extract the block list from a tab on the Tool Palette?

 

Thank you.

0 Likes
Accepted solutions (2)
2,044 Views
16 Replies
Replies (16)
Message 2 of 17

CodeDing
Advisor
Advisor

@Anonymous ,

 

You will have to explain your question further please. I do not fully understand. It sounds like you want to "insert" a block, but have the ability to select a different block before an insertion point is selected? That is the same thing as merely selecting the correct block. Thus, any typical insert command would work. Can you please explain more?

 

Best,

~DD

0 Likes
Message 3 of 17

Anonymous
Not applicable

I'll do my best.

 

Imagine I have a special group of blocks that I'm making available through a Lisp command of my own (these blocks are on the Tool Palette). What I could do is show a list of options in that command to choose the block type, but I think that taking the approach I referred to in my first comment is best because it gives you the visual information about what's the most suited block to insert (a user could use any block depending on the circumstances, everything lies in the user experience). 

 

I'll try to simplify it as much as I can. Imagine these blocks are polygons - which is not the case -. Once I enter my command (say, INSERTMYBLOCK), the user will be presented with a block (not scaling or rotation options) that still has to be inserted. If the user moves it to the theoretical insertion point, they might feel that the default block (the first in the list) is not the best option, so by clicking a button (I thought of the TAB button) they can cycle through the whole list. 

 

I knew that somebody could argue why not use visibility states (the dynamic blocks are so complex that I don't see it as an option), but your question is valid too. However, the advantage of my solution is the ease of use, I don't want the user to have to go to the insert button and choose amongst the list.

 

I hope it makes sense now. 

 

0 Likes
Message 4 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

Try the attached InsertBlockCycling.lsp with its IBC command.  First, edit the list of Block names in it, for those you want to cycle through, then APPLOAD it.  Call up the IBC command, and the first Block in the list will appear in the middle of the screen, and as soon as you move the cursor, will go to where its insertion point is at the cursor location.  Move the cursor around, and the Block will move.  Then you can cycle in either direction through the Block names in the list -- press the comma/< key and the Block will change to the previous one in the list [or the last one if currently showing the first one], or press the period/> key and it will change to the next one [or the first one if currently showing the last one].  You can continue to cycle with those keys, and move around, until you click the mouse button and the currently-showing Block will be placed.

Kent Cooper, AIA
Message 5 of 17

Anonymous
Not applicable

Hello, this is brilliant! It's exactly what I was looking for!

 

One question, how come the cursor can't snap to any reference point when inserting the block? It's as if they all had disappeared.

 

Would you recommend any quality online content to learn Auto Lisp properly? 

 

Thank you very much!

0 Likes
Message 6 of 17

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... how come the cursor can't snap to any reference point when inserting the block? ....

Would you recommend any quality online content to learn Auto Lisp properly? 

....


Object Snaps don't work because it's all based on (grread) which reads only the cursor location, not affected by Object Snap settings.  Search for terms like "osnap grread" for several threads discussing the issue.  @Lee_Mac has a >GrSnap utility< that could perhaps be worked in -- it could take me a while to get around to figuring out how, but I'll think about it.  In the meantime, I suggest placing the Block near where you want it, and immediately picking it and grip-edit moving it by its insertion point to the then-Osnappable location.

A Search here for things like "AutoLisp tutorial" or "learn AutoLisp" will find lots of threads with lots of suggestions of websites, books, etc.

Kent Cooper, AIA
Message 7 of 17

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

... One question, how come the cursor can't snap to any reference point when inserting the block? It's as if they all had disappeared.

....


 

There is one catch about this solution. Big one. And you named it. You won't get back all the drafting tools like osnaps, tracking, polar tracking... the only but limited option is to use THIS partial solution from Lee Mac.

 

Anyway, what I can imagine is this being just a menu. Circle through your block list as much as you need, then you would need to somehow confirm a selected option - it could be by Enter, Spacebar, anything.. but this extra step is necessary! and then it switches to the classic -INSERT command with supplied block name from your nice menu and then you can place your block with all the drafting features available.

Message 8 of 17

Kent1Cooper
Consultant
Consultant

Another possibility, if you would typically want to place them at Osnappable locations:  The routine could be made to immediately call up a Move command after the Block is placed, based on the insertion point, then you can take it to the Osnappable location.  So it takes a quick double pick for the final location [or a pick and ESCape if you don't want an Osnappable location], rather than a this-is-the-Block-I-want confirmation step.  Try the attached [added "O" to the end of the file name].

Kent Cooper, AIA
Message 9 of 17

Sea-Haven
Mentor
Mentor

Inserting a block then decide change it or keep, would work but would be based on insert point matching a chosen point,  then again may need a move as insert point may not be at same location of new block, then repeat etc till finally happy. Using the nice idea of < > to go through a predefined list. This would avoid the use of grread but would be a more basic version.

 

 

0 Likes
Message 10 of 17

Sea-Haven
Mentor
Mentor

Maybe something like this 

 

screenshot301.png

0 Likes
Message 11 of 17

Anonymous
Not applicable

Hello, 

 

my apologies for the late reply, I haven't had a chance to get my hands on my laptop until today.

 

I would like to thank you once again for your great help. I'll test the list file out and give you my feedback asap. If it still needs changing, I will try to figure out how can I get it to work as the way I wanted to. I also have (and want) to do my part!

 

Thank you!

0 Likes
Message 12 of 17

Anonymous
Not applicable

Thank you for the link and for your comments.

0 Likes
Message 13 of 17

Anonymous
Not applicable

Hi,

 

I struggled to understand you at first, but I think it's a great input because the user might insert the wrong block and there might be a need for a block change. Right? However, wouldn't it be better to simply delete the block and insert the one we want again by using the lisp command provided by Kent?

0 Likes
Message 14 of 17

Sea-Haven
Mentor
Mentor

Kent has offered a excellent solution as you asked for a dragging method of inserting a block and change it the issue being the various insert point of different blocks, when you change your mind.

 

The old fashioned way

 

 

 

(command "-insert" "yourblockname" pause 1 1 0)

 

 

Then ask keep or > < etc. 

0 Likes
Message 15 of 17

Anonymous
Not applicable

Hello, Kent.

 

I created this thread. Once again, thank you for your lisp, it was terrific 🙂. I have a couple of questions:

 

1) Block attributes disappear upon insertion. I've tried redefining the block after its insertion but that didn't do the trick. Puzzled. Why is that? 

 

2) One of my blocks - dynamic - has an alignment parameter but it's not showing when cycling. I guess it has to do with the fact that using grread blocks osnap, dynamic block parameters, etc. Right?

 

Just to confirm. Thank you.

 

0 Likes
Message 16 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

It wasn't designed with Attributes or Dynamic Blocks in mind.  And since it uses (entmakex) instead of an actual INSERT command, it won't prompt for Attributes or dynamic parameters.

 

On one with Attributes, if after it's in, you double-click on the Block, do you not then get the Attribute editor?

 

Try the attached [untested], which, when you pick a point, should delete the drag-around one, stop the (while) loop, and go into a regular INSERT command, leaving you after the 0 rotation to answer whatever other aspects are still needed.  You can play around with the command line -- for example, if your Blocks are built for uniform scaling, change this:

  (command "_.insert" blkname "_non" ins "" "" 0)

to this [only one scale factor]:

  (command "_.insert" blkname "_non" ins "" 0)

Or you could cut off everything after the insertion point, and finish up the command as appropriate, including scale(s) if you might want them other than 1 [or if some but not all are for uniform scaling], and rotation if you might want it other than 0:

  (command "_.insert" blkname "_non" ins)

Kent Cooper, AIA
Message 17 of 17

Anonymous
Not applicable

Hello, Kent.

 

Thank a lot once again, it works like a charm. The only thing I have to fix, though is why the Alignment parameter no longer exists. I'm going to look into it and try to understand problems related to grread.

 

Thank you!

0 Likes