Dynamic block visibility into individual block

Dynamic block visibility into individual block

sergio.corredorEZQQT
Participant Participant
6,017 Views
27 Replies
Message 1 of 28

Dynamic block visibility into individual block

sergio.corredorEZQQT
Participant
Participant

Hi everyone, first time posting in the forum.

 

I have a dynamic block that has been distributed around an area using its different visibility options. Now, I need to transform the dynamic blocks into individual blocks keeping their visibility (not sure if this is clear). 

 

For example, the dynamic block has visibility A, B and C. I used each visibility on points 1, 2 and 3 respectively. Now, I need to transform the dynamic block in point 1 to an individual block called A, the dynamic block in point 2 to an individual block called B and the dynamic block in point 3 to an individual block called C.

 

I know I can EXPLODE the dynamic blocks but then I would need to go 1 by one to make then blocks again. If I have 100 blocks it may take a long time.

 

I also have a lisp to split a dynamic block into its different visibility options. It may be helpful at the start of the project before locating all the blocks, but in my case all the blocks are already in place. Also, not sure if I can share the code here (I found it on the internet), I believe it just need to be modified to make it work as I need but I am not an expert on coding.

 

Thanks in advance for any comments.

0 Likes
Accepted solutions (1)
6,018 Views
27 Replies
Replies (27)
Message 2 of 28

dlanorh
Advisor
Advisor

Provided the block has no other dynamic properties or attributes (which will be lost); you could get a selectionset of all the blocks then filter for the block using the effectivename property.

 

Explode one block of each visibility using the vlax-invoke option of the activex "explode" method. This collects all the visible objects in the block in a list and keeps the original block. Create a new block using this list, then replace every similar block with the same visibility with the new block.

 

Should work provided you unlock all layers then reinstate on exit, but without seeing the block it's extremely difficult to assess.

 

A sample drawing containing the block would help (saved as 2010 or earlier for me)

 

 

I am not one of the robots you're looking for

0 Likes
Message 3 of 28

joselggalan
Advocate
Advocate

Can you provide an example dwg please.

0 Likes
Message 4 of 28

pbejse
Mentor
Mentor

@sergio.corredorEZQQT wrote:

Hi everyone, first time posting in the forum.


Welcome to the forum

 


@sergio.corredorEZQQT wrote:

I have a dynamic block that has been distributed around an area using its different visibility options. Now, I need to transform the dynamic blocks into individual blocks keeping their visibility (not sure if this is clear). 

You mean its current Visibilty, but does the block maintains its dynamic behavior if any?

 


@sergio.corredorEZQQT wrote:

 

I also have a lisp to split a dynamic block into its different visibility options


Go ahead and share the lisp, it may be useful.

 

 

0 Likes
Message 5 of 28

Libbya
Mentor
Mentor

Turn the linework within each visibility state into a block.  Insert that block into the visibility state to replace the prior linework.  After that, you can explode all of the insertions of the dynamic block in model space and at each prior insertion point you will now have the nested block that was within each visibility state.  See screencast.

 

 

Message 6 of 28

dlanorh
Advisor
Advisor

Any dynamic block that only has visibility states should, when inserted, produce an anonymous block for each visibility state if that visibility state is activated. Using lisp you can select one of these blocks and then rename that anonymous block definition in the block table to have a non anonymous name. This will update all blocks referencing that anonymous block with the same visibility state and it is then a simple matter of constructing a selection set of those blocks converting the first one to a named static block using the "converttostaticblock" method and replacing all the rest with the new static block. No exploding or changing block definitions needed. The crux is the highlighted text above.

 

I am not one of the robots you're looking for

0 Likes
Message 7 of 28

Libbya
Mentor
Mentor

That's all fine and dandy but I don't think that it is any simpler or easier than the method I show.

0 Likes
Message 8 of 28

sergio.corredorEZQQT
Participant
Participant

Hi everyone,

 

Thanks for all your responses. I have attached the xref I am using and the lisp to split the visibility states into individual blocks.

 

As you can see, exploding the dynamic block and then creating the individual blocks may take a long time.

0 Likes
Message 9 of 28

dlanorh
Advisor
Advisor

I cannot open the drawing as it is saved in a later version to mine (2012). Can you repost the drawing saved in AutoCAD 2010 or earlier format.

 

I am not one of the robots you're looking for

0 Likes
Message 10 of 28

sergio.corredorEZQQT
Participant
Participant

Hi dlanorh,

 

Version 2010 attached. Thanks for your help.

Message 11 of 28

dlanorh
Advisor
Advisor

Thanks.

 

Converting to a static block will maintain the invisible attributes for each block, but each block must have a unique name as per your supplied lisp. I would suggest joining the original block name with a dash "-" and the value of the station_no attribute, which I assume will be unique for each pole; or did you have something else in mind?

 

You also need to be aware that the block will no longer be annotative.

 

I am not one of the robots you're looking for

0 Likes
Message 12 of 28

dlanorh
Advisor
Advisor

OK. Had a good play with this, but as the block contains attributes your options are extremely limited if you wish to retain all the blocks elements. The limiting factors here are the invisible attributes (there is at least one unique attribute value per block). This could cause any new block to itself become anonymous. Also each block has two rotation parameter, one for the light itself and a second for most (not all) of the attributes. These are not always the same. 

 

A staight convert from dynamic to static. This is quicker, easier and has the same effect as exploding and reforming the block, but as with the explode option, requires a unique new name for every block instance as mentioned in my previous post. This new name (IMHO) should include the visibility state name and either a count number (1 ... n) or the value of the unique and visible "STATION-NO" attribute.

 

 

 

I am not one of the robots you're looking for

0 Likes
Message 13 of 28

sergio.corredorEZQQT
Participant
Participant

Thankfully I don't need the attributes in the individual blocks (sorry I didn't mention this before), but I really need to keep the block in the same angle. In other words, I don't mind the number itself, I only need that if the dynamic block was looking at north-east, the individual block stays looking at the same direction.

 

About the name, I think having the STATION-NO attribute included in the block name would be perfect.

 

Following what you said I have found the attached lisp that converts the blocks and keeps the attributes (again, not necessary but it doesn't hurt anyone), but it creates the name as "STATIC_XX". Can you please check if you can change it so it includes the VISIBILITY name and the STATION-NO value, as you mentioned before?

 

We are 99% there, thanks a lot @dlanorh!

0 Likes
Message 14 of 28

dlanorh
Advisor
Advisor

OK. Try the attached. Test on your supplied drawing and working in 2012. This lisp has a small user section where you can alter how the lisp works. There are 2 local variables lflg and tag

 

lflg : This controls where the selection set will search. It is currently set to nil (false whole drawing) but if set to T (true) it will only search the layer of the selected block

 

tag : this is the name of the tag containing a unique value for renaming the block. If set to nil the lisp will revert to an accumulative  number starting at 1

 

You are asked to select one instance of the dynamic block to process. This must be a dynamic block with visibility state(s) or it will not exit the while loop. Any selection error should be indicated by a popup alert box before returning to the "Select Block" prompt.

 

As these blocks have attributes I have included an "attsync" after the block is converted to static. This is there to ensure the block updates to its non dynamic state.

 

If you don't require the attributes you can remove all or some of them. This could also apply to the "STATION-NO" attribute and its surround if it is no longer required. This in theory would allow one block per visibility state which could be orientated using the "angle1" dynamic parameter extracted before converting to static. I haven't tested this however so it may not be possible.

 

Once the lisp is loaded type d2sbv to run

 

 

 

I am not one of the robots you're looking for

Message 15 of 28

sergio.corredorEZQQT
Participant
Participant

Thanks a lot @dlanorh, this is perfect.

 

I would have a last request if you don't mind. Even when the process works perfectly to what I need, I showed the results to some colleges and they asked if is it possible to add the rotation value to the individual block.

 

I tested if your lisp keeps the normal block rotation and it does. But, in this particular case only the Angle1 rotation was used. Do you think there is a way to add the Angle1 rotation to the block rotation and then make the Angle1 rotation 0, all before transforming the dynamic block into individual blocks? Or any other way to have the individual block with a rotation value?

 

Thanks again @dlanorh 

 

0 Likes
Message 16 of 28

dlanorh
Advisor
Advisor
The lisp only converts the exiting block from dynamic to static and renames it. No other changes are made an it inherits the rotation of the existing block only because the rotation perameter is removed.

Applying a rotation to the block itself would mean inserting a new block and you would lose any repositioning of the STATION-NO attribute and its surround.

I'm quite busy at the moment, but have briefly tested a routine that removes all the attributes (including the STATION-NO attribute and its surround/wipeout), in fact anything in the block that is not on layer "0". It should be possible to remove all items on layer "defpoints" which would leave the visible attribute and rotate this block to the same angle as the "angle1" parameter, but your visible attribute would lose its position and be unmoveable since the move action would be gone.

Let me know what you want to do, and if you don't get a reply PM me as I don't usually frequent the dynamic block forum.

I am not one of the robots you're looking for

0 Likes
Message 17 of 28

sergio.corredorEZQQT
Participant
Participant

Hi @dlanorh 

 

Sorry for my late reply. I tried to PM you but I am not sure how to do it.

 

If I loose the visual STATION-NO attribute but the value is still in the block name as per your lisp, that won't be a problem. Thinking about it, if we can remove the visual STATION-NO attribution it will be good.

0 Likes
Message 18 of 28

dlanorh
Advisor
Advisor

@sergio.corredorEZQQT wrote:

Hi @dlanorh 

 

Sorry for my late reply. I tried to PM you but I am not sure how to do it.

 

If I loose the visual STATION-NO attribute but the value is still in the block name as per your lisp, that won't be a problem. Thinking about it, if we can remove the visual STATION-NO attribution it will be good.


Not sure I still follow. is that :

 

1. Remove all the attributes, and STN-NO surround. Block becomes original Block name + visibility state and block rotated to "angle1" value? This will mean one block per visibility state.

 

2. Remove all attributes, Block becomes  original Block name + visibility state + val STN-NO. This will increase the number of blocks in the drawing as each insert will become a seperate block.

 

or

 

3. As 1 except make STN-NO attribute invisible? This allows one block per visibility state, but with an attribute so block may become anonymous.

 

I am not one of the robots you're looking for

0 Likes
Message 19 of 28

sergio.corredorEZQQT
Participant
Participant

Hi @dlanorh 

 

Is more like option 2, remove attributes, the block name will be visibility + station-no and block rotated to "angle1" value.

 

I attached an example of the dynamic block and the best outcome for the individual block as per previous sentence.

 

Thanks a lot for your help.

0 Likes
Message 20 of 28

dlanorh
Advisor
Advisor

Sorry, I can't open the drawing. It needs to be save as AutoCAD 2010 or earlier.

 

Should have time to get to this over the weekend.

 

I am not one of the robots you're looking for

0 Likes