Hello Everyone,
I'm doing a repetitive task that is to change the view label text height from value x.xxxin to 0.188 in. Tentatively I have to edit 4 or 5 view labels per sheet to modify the text height (one .idw may contain multiple sheets). I'm doing this task by editing the view label and changing the height one by one in a text editor. Can anyone suggest to me a ilogic code that can help me? I would appreciate
This has something similar you could use:
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-code-to-change-view-label-text/m...
And this is the usual go-to reference:
http://inventortrenches.blogspot.com/2012/01/set-your-drawing-view-labels-to-use.html
More here:
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/custom-user-properties-in-view-label-of...
and here:
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-code-for-drawing-view-label-chan...
CAD and PLM admin | My ideas | Inventor-Vault Expert GPT (my AI brain)
Thank you for your reply @Gabriel_Watson,
It is hard for me to formulate a workable code since I'm new to programming and macro.
I would need a code that can modify the available text height alone in the selected view label. All your reference links are for new properties added to the view labels and other related things.
(E.g. The existing available text in the view label is "FRONT VIEW" with a text height of 0.197. I need to change the text height from 0.197 to 0.188).
@anandaraj.ganesanGP4H9 Try this..
This will set the view label of each view on each sheet to "Front View" and make the font height .187"
oFSize = 0.47498 'font size in cm
oNewLabel = "<StyleOverride FontSize='" & oFSize & "'>FRONT VIEW </StyleOverride>"
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
oSheets = ThisDoc.Document.Sheets
For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
oView.Label.FormattedText = oNewLabel
Next
Next
And this is more generic.. It just changes the font and can be used with any label text.
oFSize = 0.47498 'font size in cm
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
oSheets = ThisDoc.Document.Sheets
For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
oOldLabel = oView.Label.Text
oView.Label.FormattedText = "<StyleOverride FontSize='" & oFSize & "'>" & oOldLabel & "</StyleOverride>"
Next
Next
Thanks a lot, @mcgyvr for your support,
This macro works great but all the view label values are getting changed and overwritten to nonassociated values (E.g. View label stacked by a Part Number from the model, view scale, view name) These values are overwritten with the same value.
It is really helpful if the height alone gets changed.
@anandaraj.ganesanGP4H9 Are your view labels always consistent (aka have the same data in them)?
Can you show pictures of how each one is formatted specifically?
Each sheet has a Front view, top view, and side.
Top view label has only have top view text.
Front view has below text view label. Part number value will be called from the model. After the Part number value, some additional text also gets added that is different in sheet by sheet to indicate the variable.
Side view label has only had Side view text.
Section and detail view may get added.
Hope this will give more clarity on my need.
Thank you.,
Is this a permanent change in all drawings? If so ideally you would change the view label font style in the style editor and apply this as a global change. How this will update in your existing drawings will depend on which style was being used. You could use some ilogic to update the style also but just hitting the update from style should work. The method being used in the post previously is deleting the view rep and adding a new label. Only items contained in the ilogic code will be added in. Ilogic will work but you really are only changing the local copy and as so the issue will persist in all future drawings should you wish to do a new change.
Can't find what you're looking for? Ask the community or share your knowledge.