Dynamic Block to Static Block - Renamed after Visibility State

Dynamic Block to Static Block - Renamed after Visibility State

Anonymous
Not applicable
4,191 Views
20 Replies
Message 1 of 21

Dynamic Block to Static Block - Renamed after Visibility State

Anonymous
Not applicable

Hi all,

This post sort of follows on from an existing forum post but I wanted a new post to get some attention. The original post relates to a LISP code that turns Dynamic Blocks into Static Blocks, renamed to: STATIC_*sequential number*.

The post can found here: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-dynamic-block-to-regular-bloc...

 

The above post addressed naming the new static blocks after the Dynamic Block name, followed by a sequential number (i.e.).

What I would like to achieve is the same process but with a static block name matching the visibility state (ideally with the sequential number suffix removed) of the dynamic block when the LISP is run.

I've attached the existing .lsp using the block name setup from the previous post linked above.

I have very limited LISP/VLISP experience and knowledge and have only ever done a tiny bit of basic AutoCAD scripting.

 

If anyone could help it would be greatly appreciated and if anyone needs any additional information of details please let me know!

Thanks in advance,

 

Jack

0 Likes
4,192 Views
20 Replies
Replies (20)
Message 2 of 21

Anonymous
Not applicable

@pbejse

@hmsilva

I hope you gentlemen don't mind me tagging you in this post, I've seen your expertise in LISP all over the forums and am hoping you can help me out.

0 Likes
Message 3 of 21

pbejse
Mentor
Mentor

@Anonymous wrote:

 

.... What I would like to achieve is the same process but with a static block name matching the visibility state (ideally with the sequential number suffix removed) of the dynamic block when the LISP is run.

 

If anyone could help it would be greatly appreciated and if anyone needs any additional information of details please let me know!..

 

Jack


Hello Jack,

 

Sure we can help, I have a question for you, what will happen if you have two or more dynamic block with the same visibility? and if by chance the dynamic block has other parameters like stretch / rotate but on the same visibility state as another block?  The two  will have the same visibility state but different look.

 

If you are dealing only with just visibility states and no other parameters then its not going to be an issue, the program will instead "replace" the dynamic block with the same visibility as of those already processed.

 

Sounds good to you?

 

0 Likes
Message 4 of 21

braudpat
Mentor
Mentor

 

Hello

 

I am interested ALSO by a Lisp/VLisp routine (Dynamic to a few different Static Blocks) for Dynamic Blocks

when they have ONLY visibility parameters !

No other parameters (Stretch, Rotation, Mirror, etc)

 

I imagine it's possible to test the Dynamic block to see if it has only visibility parameters !?

 

Thanks, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 5 of 21

pbejse
Mentor
Mentor

@braudpat wrote:

 

Hello

 

I am interested ALSO by a Lisp/VLisp routine (Dynamic to a few different Static Blocks) for Dynamic Blocks

when they have ONLY visibility parameters !

No other parameters (Stretch, Rotation, Mirror, etc)

 

I imagine it's possible to test the Dynamic block to see if it has only visibility parameters !?

 

Thanks, Regards, Patrice

 


Oh yes, we can. As a matter of fact even if there are any parameters other than visibility I will just ignore them ( maybe / maybe not ). Smiley Very Happy 

 

I have the idea on my head but let's wait on J_Gibbins before we start Patrice, Are you okay with that? 

 

Besides, any forum members here can modify the code if they choose to do so. Two ( more ) heads are better than ( n ) one. 🙂 

 

 

;;;				kudos to orignal author - MP				;;;
;;;		http://www.theswamp.org/index.php?topic=32681.msg382548#msg382548	;;;

pBe

 

EDIT: There are actually a ton of solutions on that link, perhaps you can start there J_Gibbins.

Message 6 of 21

pbejse
Mentor
Mentor

I have some time to kill so try the attached modified Lisp  [ Undynamic - Use Visibility Name.lsp ]

 

< Limited testing >

 

command: UnDynamicVisName

 

As I've said before, Dynamic blocks of the same visibility states will be "replaced" by the existing block of the first instance that was submitted to the "cleansing" 🙂

 

HTH

 

Message 7 of 21

Anonymous
Not applicable

Hmmm it's a loaded question.

For a bit of context the blocks I'm trying to apply this to are P&ID symbols (valves, actuators, instrument bubbles, etc.) so it varies.

 

 

But off the top of my head every visibility state contains at least one additional dynamic parameter (usually a lookup table, relating to dimensions).

 

Some blocks share visibility states though that are quite complex and contain flips, rotates, mirrors, lookup tables etc.

 

0 Likes
Message 8 of 21

Anonymous
Not applicable

Thanks pbejse! 

So far from testing it reverts blocks to their default states (flips, rotations etc.), including parameters associated with a lookup table, which is what you described would be the case. That script is blocking them by visibility state but unfortunately it is resetting any other dynamic parameters (such as flip, rotate) to their default setting.

I went and reread the rest of that post on The Swamp and there were some great revisions there, Lee Mac's revision of the script is running the same as the one you attached previously.

I've also noticed sometimes I have to occasionally run the command twice as it misses some blocks (for whatever reason) and also that on any blocks that had non-default parameters (flipped, rotated etc.) it would leave a 'ghost' of the dynamic drop downs and icons on the block, but these just disappeared if you clicked any of them and the block has definitely been converted to static (also unsure why).

Neither of those issues are huge but ideally I would like a script that can manage the set, non-default dynamic parameters. I imagine this probably would take quite a lot of effort because of obvious block definitions etc.

Also after reading The Swamp post I just wanted to take a moment to thank yourself and the many other talented programmers out there for taking the time to help users like myself with these issues, it had never occurred to me how much I image your time and intellectual property is stolen and passed off by others as their own.

Thanks again for your help, I really appreciate you taking the time to try and help me find a solution.

 

Cheers

 

Jack

 

0 Likes
Message 9 of 21

Ranjit_Singh
Advisor
Advisor

Maybe post a sample drawing with subject dynamic blocks that have all the parameters set. Just a sample set that we can work with.

0 Likes
Message 10 of 21

braudpat
Mentor
Mentor

 

Hello EE Friend pbejse

 

1) Thanks

 

2) Your routine seems to do the Job !

 

3) Please is it possible to get a small improvment ?

Actually you are running on ALL the DWG !

Is it possible to run on a CLASSIC AutoCAD selection ?

 

4) And the Top would be a warning to go on (Yes/No) if the routine detects that they are NON Visibility parameters on the selected Dynam Blocks !!

 

5) Please find attached a small Test DWG (Block with visibility states) ...

 

Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 11 of 21

pbejse
Mentor
Mentor

@Anonymous wrote:

Thanks pbejse! 

So far from testing it reverts blocks to their default states (flips, rotations etc.), including parameters associated with a lookup table, which is what you described would be the case. That script is blocking them by visibility state but unfortunately it is resetting any other dynamic parameters (such as flip, rotate) to their default setting....


Now you know why the need for the number suffix. It does not actually revert back to the default values, it just so happens that the first block the program encountered is in "that" particular state. 

 

As you may already know, you can't have a block having the same name but different contents ( hence the need for dynamic blocks ). We can modify the code to consider the current state and give it a name based on visibility and not block name as the original codes but still having the number prefix when the visibility block name already exists, I guess there is just no way around it.

 


I've also noticed sometimes I have to occasionally run the command twice ....

.......non-default dynamic parameters. I imagine this probably would take quite a lot of effort because of obvious block definitions etc. 


As Ranjit.Singh suggested, can you post a sample drawing so we can fully understand what you mean by ↑.


Also after reading The Swamp post I just .......how much I image your time and intellectual property is stolen and passed off by others as their own. 


I gave up policing years ago. It can't be helped.


@Anonymous wrote:

Thanks again for your help, I really appreciate you taking the time to try and help me find a solution.

 

Cheers

 

Jack 


You are welcome. We try to help as much as we can. 

 

pBe

Message 12 of 21

pbejse
Mentor
Mentor

@braudpat wrote:

 

Hello EE Friend pbejse

 

3) Please is it possible to get a small improvment ?

Actually you are running on ALL the DWG !

Is it possible to run on a CLASSIC AutoCAD selection ?

 

4) And the Top would be a warning to go on (Yes/No) if the routine detects that they are NON Visibility parameters on the selected Dynam Blocks !! 

 

Regards, Patrice

 


Hello to you too braudpat

 

Yes it is possible  |  Same goes for that too

 

Post the code later.

 

 

0 Likes
Message 13 of 21

pbejse
Mentor
Mentor

@braudpat wrote:

 

 

.....4) And the Top would be a warning to go on (Yes/No) if the routine detects that they are NON Visibility parameters on the selected Dynam Blocks !!

 ...

 

 


Ok, back in front of a computer, Why the need for the warning for ( Yes/No ) braudpat?  Are you wanting this for single selection? if selected block is not dynamic then NO select again or Yes then proceed to rename the dblock?

 

Or would you rather have multiple selections and then highlight the non-conforming block(s) [ if any ] ? Not really sure about the Yes/No warning. Tell us more.

 

 

0 Likes
Message 14 of 21

braudpat
Mentor
Mentor
Hello

For me:

1) The routine must retain only Dynam blocks from the classic ACAD sélection...

2) If they are Dynam parameters OTHER than Visibility, I would like the question :
Do you want really to proceed ?

If YES go... And loss these Dynam parameters...

3) IF Only Visibility Dynam params, please proceed immédiately !

Do you seee what I mean ?

Regards, Patrice
Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 15 of 21

pbejse
Mentor
Mentor

@braudpat wrote:
Hello
... Do you seee what I mean ?

Regards, Patrice

Yes, got it. Writing code......

0 Likes
Message 16 of 21

pbejse
Mentor
Mentor
1) The routine must retain only Dynam blocks from the classic ACAD sélection...   
2) If they are Dynam parameters OTHER than Visibility, I would like the question : 
3) IF Only Visibility Dynam params, please proceed immédiately ! 

That was fun 🙂 [ try the  attached code ]

 

HTH 


@Anonymous wrote:

...
I've also noticed sometimes I have to occasionally run the command twice as it misses some blocks (for whatever reason) and also that on any blocks that had non-default parameters (flipped, rotated etc.) it would leave a 'ghost' of the dynamic drop downs and icons on the block, but these just disappeared if you clicked any of them and the block has definitely been converted to static (also unsure why).
... 


 Now I understand what J_Gibbins meant by 'ghost', need to look into that later...

 

Message 17 of 21

Anonymous
Not applicable

I've attached an example P&ID drawing that I've tidied unnecessary information out of.

Some of dynamic blocks in there include:

 

  • CONTD ARROW
  • VALVE
  • ACTUATOR
  • INSTRUMENT
  • REDUCER
  • INSULATION
  • PIPE CONNECTION
  • HOSE
  • HOSE CONNECTION
  • AGUG
  • POINT
  • FLOW ELEMENT
  • ARROW
  • BLIND-SPACER

 

These represent the blocks that would be most commonly used and across them there is a varying degree of dynamic properties.

 

Whilst testing/looking through I'd also be more than happy for any comments or constructive criticism on how I've produced these blocks and whether there was a better/more efficient way to do so.

 

You'll have to excuse that I'm sure they're not perfect (adequately labelled parameters, good use of parameters, etc.) as I only first started playing with Dynamic Blocks a few weeks ago and have been trying to implement them simultaneously with project work (which obviously takes priority!). Maybe a personal message might be better so the post isn't cluttered with irrelevant replies to the original topic.

 

Thank you again 🙂

0 Likes
Message 18 of 21

braudpat
Mentor
Mentor

 

Hello Virtual EE Friend @pbejse

 

THANKS your routine is great !

 

I hope it will help other ACAD Dynamic Blocks Users !?

 

Thanks again from the French Froggy EE, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 19 of 21

pbejse
Mentor
Mentor

@braudpat wrote:

 

Hello Virtual EE Friend @pbejse

 

THANKS your routine is great !

 


My pleasure.

 

Good to know it helps.  

 

You may want to change one item there.

 

 

(getstring "\nSelected object is NOT a Dynamic Block <Press Enter To continue>")

to 

 

 

(getstring "\nSelected object doesn't have Visibility parameter <Press Enter To continue>")

 

Cheers

 

pBe

 

 

0 Likes
Message 20 of 21

nbortolussi
Participant
Participant

I know this is an older post, but I was hoping someone could help me to modify this lisp. 

I am not too familiar with lsp....i used it in school a little but that was 18 yrs ago.

Instead of just the VisState as the new static block name, I would like it to name with Original Block Name (visibility state name).

additionally, but not as important...maybe even an option to add the sequential number suffix back in...in cases where the block has other dynamic parameters changing in the dynamic block and the first Static version has already been created (without the seq num suffix).  I am not sure if it would be possible to overwrite that first block or not...but maybe a option to overwrite (if doable) or create new with the next seq num.

 

Thanks in advance,

Nic

 

0 Likes