- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need changing the view scale format: just to change : to / or vice versa while existing scale remains the same.
Could someone help me.
Thanks.
'https://forums.autodesk.com/t5/inventor-customization/ilogic-code-to-change-view-label-text/td-p/3625130
'https://forums.autodesk.com/t5/inventor-customization/exsisting-ilogic-rule-view-label-fitted-with-item-number/td-p/6323006
oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.Count = 0 Then
MessageBox.Show("SELECT A DRAWING VIEW FIRST!", "INSTRUCTIONS")
Exit Sub
End If
Dim oView_Names As New ArrayList
oView_Names.Add("DESN - PN")
oView_Names.Add("DESN - VL")
oView_Selected = InputListBox("Prompt", oView_Names, oView_Names(0), Title := "Title", ListName := "List")
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = TryCast(oSSet.Item(1), DrawingView)
If oView IsNot Nothing Then
oView.ShowLabel = True
If oView_Selected = "DESN - PN" Then
'format the model iproperties
oDescription = "<StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
oPartNumber = "<StyleOverride Underline='True'> - <Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
'oStringMass = "<Br/><StyleOverride Underline='False' FontSize='0.35'>EST UNIT MASS = <PhysicalProperty PhysicalPropertyID='72449' Precision='2'>MASS</PhysicalProperty></StyleOverride>"
oStringScale = "<Br/><StyleOverride FontSize='0.3'>(SCALE: <DrawingViewScale/>)</StyleOverride>"
'add to the view label
oView.Label.FormattedText = oDescription & oPartNumber & oStringMass & oStringScale
Else If oView_Selected = "DESN - VL" Then
Dim DESN_VLs As New ArrayList
DESN_VLs.Add(iProperties.Value(oModelDoc, "Custom", "DESN_VL"))
DESN_VLs.Add("HSS")
DESN_VLs.Add("BEAM WELDMENT")
DESN_VLs.Add("BRACING WELDMENT")
DESN_VLs.Add("PLATE")
DESN_VLs.Add("ANGLE")
DESN_VL_Selected = InputListBox("Prompt", DESN_VLs, DESN_VLs(0), Title := "DESCRIPTION for VL", ListName := "Select")
DESN_VL_EDIT = InputBox("EDIT/ACCEPT DESN_VL ", "Title", DESN_VL_Selected)
iProperties.Value(oModelDoc, "Custom", "DESN_VL") = DESN_VL_EDIT
oView_Selected_New = InputBox("EDIT/ACCEPT CUSTOM TEXT: ", "TYPE TEXT TO SUIT", DESN_VL_EDIT)
'format the text first line
oStringItem = "<StyleOverride Underline='True'>" & oView_Selected_New & "</StyleOverride>"
'oDescription = "<StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
oPartNumber = "<StyleOverride Underline='True'> - <Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
'oStringMass = "<Br/><StyleOverride Underline='False' FontSize='0.35'>EST UNIT MASS = <PhysicalProperty PhysicalPropertyID='72449' Precision='2'>MASS</PhysicalProperty></StyleOverride>"
oStringScale = "<Br/><StyleOverride FontSize='0.3'>(SCALE: <DrawingViewScale/>)</StyleOverride>"
'add to the view label
oView.Label.FormattedText = oStringItem & oPartNumber & oStringScale
End If
Else
MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
'Dim oApp As Application: oApp = ThisApplication
'Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
'Dim oView As DrawingView
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, to change the character that is used on the scale, you could use an ilogic rule like the following
Dim doc As DrawingDocument = ThisDoc.Document Dim oScale As String For Each oSheet As Sheet In doc.Sheets For Each oView As DrawingView In oSheet.DrawingViews oScale = oView.ScaleString If InStr(oScale, ":") <> 0 Then oView.ScaleString = oScale.Replace(":","/") If InStr(oScale, "/") <> 0 Then oView.ScaleString = oScale.Replace("/",":") Next Next
Try this rule in Inv 2020 and it works very well
I hope this helps with your problem. Regards
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Sergio.
Great help. I am also doing with
- DETAIL views (view name is static in view label)
- SECTION views (section name static in view label)
- incorporate Custom Properties, say GRADE in the sample (not sure how to do!)
Could you kindly help me to get then in the view labels.
Sorry for having to bother you.
Thanks a lot.
Sample attached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @RoyWickrama_RWEI. Not sure if you ever figured out how to do your final request here or not, but here's a tip to help you figure out how to write the FormattedText portion of the code. The FormattedText uses XML programming language within, so it's a bit tricky. If you're not a pro at writing and understatding XML, usually the best to get your String formatted the way you want it is to use something like a MessageBox.Show(), MsgBox(), or InputBox().
Create the View label the way you want it manually on the drawing, then access it by code and show the oView.Label.FormattedText in one of those messages to youself. That will show you exactly how it is formatted "behind the scene". If you use either InputBox() or InputListBox() you will be able to select and copy the resulting string.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Sergio,
I'm using your rule but changed it to go from "/" to "=". It works great when running it from inside a drawing.
I want it to run automatically when I open a new drawing so that when I add the first view, the scale format is correct. I've tried playing with the trigger settings but haven't been able to get it to work. I'm thinking it may have something to do with the drawing not having any views when first opening. Could that be the case? Is it possible to do this?
Thanks in advance for your help.
Intel Core i7-9700K @ 3.60Ghz
16GB DDR4 RAM
NVIDIA GeForce RTX 2060 Super GPU
Windows 10 Professional 64-bit