Announcements

Announcement: We’re aware of an issue affecting starting a new topic from category pages and creating new blog posts. New topics can still be started directly from the relevant board. Learn more here.

Using VBA to edit tag positions in library symbols and update the drawing

Using VBA to edit tag positions in library symbols and update the drawing

revans1234
Enthusiast Enthusiast
1,427 Views
6 Replies
Message 1 of 7

Using VBA to edit tag positions in library symbols and update the drawing

revans1234
Enthusiast
Enthusiast

Hello,

 

I have a large drawing with many different symbols in use, that is currently being worked on. However all the symbols have the tags for install, location and tagname in the same size font in a similar position.

 

The client would like the tagname clearer larger and the install and location codes smaller. Since I only work for this client it is important to find a way to do it.

 

I think there is a library tool that can change fonts and height in library symbols on a library basis, but I would like to know if there is a vba way of not only this but shifting the co-ordinates of tags by hardcoded values based on the tagname with the symbol. The catch is this is within the symbol definition- these are not isolated tag attributes on the drawing.

 

Also for me I would prefer to alter only the symbols in use on the drawing. If I sent a routine to alter the entrie library it would take an enormous time to run.

 

However the key unknows in VBAn for me are opening, searching, altering, saving, updating the symbol definitions.

 

I can of course edit each symbol in AESYMBUILDER and AESWAPBLOCK them back. I just wondered if anyone in the Community had met this problem for large numbers of symbols and no time available and how they solved it.

 

Thanks for your advice and regards to all of you,

 

Roger.

0 Likes
Accepted solutions (1)
1,428 Views
6 Replies
Replies (6)
Message 2 of 7

rhesusminus
Mentor
Mentor
It would be a rather quick job to make a VBA macro that changes the active drawing, if what need to be done is th change the text style of the TAG*, LOC and INST attributes, and then move the LOC and INST attributes to a predefined postition relative to the TAG attribute.

Is this what you want to achieve? Can you send me an example drawing?

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Autodesk Expert Elite Alumni
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Message 3 of 7

revans1234
Enthusiast
Enthusiast
Hello Rhesusminus,
Thank you for the reply.
Yes, what you say is right. That is what I want to do.
I have sent a drawing with this. If it fails to get through an extract is below.
So the 200Q2 needs to be another font and size (say 1.5 times the size), but the 35 and U03/BMS1 need to be smaller and moved to allow for the tag height change.
[cid:[email protected]]
The challenge is that the attributes are inside the symbol for the component (the isolator in this case). So the symbol definition would need to change and the drawing updated to solve it.
Also it is fine to do this- in other words, there is no problem changing the library files in this case. I am using a library copy for this project so it will not affect any other drawings.
Thanks for your help- also the PLC update VBA you did in May solved the problem I had completely.
Best regards,
Roger.
0 Likes
Message 4 of 7

rhesusminus
Mentor
Mentor
Accepted solution
The nice things about attributes in a block is that we can change them without changing the block definition.
So, you won't change the symbols for all your customers, only the ones in the drawings for this customer.

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Autodesk Expert Elite Alumni
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Message 5 of 7

revans1234
Enthusiast
Enthusiast

W30 -679- INFO FOR ACE FORUM- extract e-200 isolator.png

I'll try again with the drawing.

0 Likes
Message 6 of 7

revans1234
Enthusiast
Enthusiast

Hello rhesusminus,

 

I've just tried something like this, and it does work. It seems that even though the block definition appears fixed, once it has been inserted then the attributes can be moved.

 

It will need some more work as if I move the attributes relative to where they are to get the new position, I need to add an interlock (perhaps using an attribute in the block) to remember that I have done it. Otherwise if the code runs more than once the attributes get shifted too far.

 

It still is the way to go for large numbers of symbols, so I have marked it as the solution.

 

Thanks again,

 

Roger.

0 Likes
Message 7 of 7

rhesusminus
Mentor
Mentor
If you only change the AcadAttributeReferences in the drawing, and not the AcadAttribte in the block definition, you can always get the original location from the attributes there. So that if you run the macro several times, it's always relative to the original.

Anyways, good work!

If you should want some help with the VBA code, please ask!

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Autodesk Expert Elite Alumni
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes