iLogic - Replacing Datum ID and View Annotation Styles

iLogic - Replacing Datum ID and View Annotation Styles

Anonymous
Not applicable
1,000 Views
2 Replies
Message 1 of 3

iLogic - Replacing Datum ID and View Annotation Styles

Anonymous
Not applicable

@Jon.Balgley

@Curtis_Waguespack

@PaulMunford

 

 

I am struggling with writing Code to replace all Datum IDs and View Annotations, as shown in the picture, on an existing drawing. This will be part of my program to update all older drawings to the latest standards.

 

I know how to do this for all the other styles I am replacing, but I am struggling with finding the correct style objects. I have attached code for everything I want to do minus the code for replacing Datum IDs and View Annotations.

 

Style Help.jpg

 

SyntaxEditor Code Snippet

'---------------------START OF iLogic
Dim Message As Integer
Dim N As Integer'---------------------TOTAL NUMBER OF SHEETS

'---------------------PARAMETER CHECK
Try
oTest = Parameter("DIM_STYLE")
Catch
'---------------------MULTI-VALUE TEXT PARAMETER CREATION
ThisDoc.Document.Parameters.UserParameters.AddByValue("DIM_STYLE", "METRIC", UnitsTypeEnum.kTextUnits)
'---------------------SET LIST
MultiValue.SetList("DIM_STYLE", "METRIC", "INCH")
End Try
Parameter.Param("DIM_STYLE").IsKey = True

'---------------THIS SECTION COUNTS THE TOTAL NUMBER OF SHEETS
Dim oDrawing As DrawingDocument
oDrawing = ThisApplication.ActiveDocument
Dim osheet As Sheet
i = 0
'---------------------COUNT TOTAL NUMBER OF SHEETS
For Each osheet In oDrawing.Sheets
If osheet.ExcludeFromCount = True Then
i = i + 1
Else
End If
Next
'---------------------REMOVE THE EXCLUDED SHEET FROM THE TOTAL NUMBER OF SHEETS
oMySheetCount = oDrawing.Sheets.Count - i
N = oMySheetCount

'---------------------------------------Message Box asking the user if they wish to continue---------------------------------
Message = MessageBox.Show("This operation will change all Dimensions on " & N & " Sheets. Press the OK button, if you wish to continue.", "Drawing Style Change", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
If Message = 2 Then 
Exit Sub
Else


'---------------THIS SECTION CHANGES THE DRAWING STYLE'---------------------PICK DRAWING UNITS
DIM_STYLE= InputListBox("SELECT THE DESIRED DRAWING UNITS", MultiValue.List("DIM_STYLE"), DIM_STYLE, Title := "DRAWING UNITS", ListName := "DWG UNITS SELECTIONS")
InventorVb.DocumentUpdate()

'---------------------SECTION TO CHANGE ALL DIMENSIONS FEATURE CONTROL FRAMES TO THE CORRECT STYLES

'---------------------DEFINE THE DRAWING DOCUMENT
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
'---------------------LOOK AT EACH SHEET
For Each oSheet In oDrawDoc.Sheets
'---------------------REFERENCE TO THE STYLE MANAGER
    Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager
'---------------------GET THE REFERENCE TO THE TARGET DIMENSION STYLE (BY NAME)
    Dim oDimStyle As DimensionStyle
    Dim oDimStyle2 As DimensionStyle
    DimStyle = DIM_STYLE
    If DimStyle = "INCH" Then
        oDimStyle = oStylesMgr.DimensionStyles.Item("ANSI - IN [MM]")
        oDimStyle2 = oStylesMgr.DimensionStyles.Item("ANSI - ORDINATE - IN [MM]")
        oFCFStyle = oStylesMgr.FeatureControlFrameStyles.Item("ANSI - FCF - INCH")
        oStylesMgr.ActiveStandardStyle = oStylesMgr.StandardStyles.Item("ANSI - FSE - INCH")
        iProperties.Value("Custom", "DIM_UNIT_NOTE") = "DIMENSIONS ARE IN INCHES. DIMENSIONS SHOWN IN BRACKETS [ ] ARE IN MILLIMETERS."
        iProperties.Value("Custom", "PRIMARY WEIGHT") = "LB"
        iProperties.Value("Custom", "SECONDARY WEIGHT") = "KG"
    ElseIf DimStyle = "METRIC" Then
        oDimStyle = oStylesMgr.DimensionStyles.Item("ANSI - MM")
        oDimStyle2 = oStylesMgr.DimensionStyles.Item("ANSI - ORDINATE - MM")
        oFCFStyle = oStylesMgr.FeatureControlFrameStyles.Item("ANSI - FCF - MM")
        oStylesMgr.ActiveStandardStyle = oStylesMgr.StandardStyles.Item("ANSI - FSE - MM")
        iProperties.Value("Custom", "DIM_UNIT_NOTE") = "DIMENSIONS ARE IN MILLIMETERS."
        iProperties.Value("Custom", "PRIMARY WEIGHT") = "KG"
        iProperties.Value("Custom", "SECONDARY WEIGHT") = "LB"
    End If
'---------------------DECLARING THE VARIABLES
    Dim oDims As DrawingDimensions = oSheet.DrawingDimensions    
    Dim oGenDim As GeneralDimension    
    Dim oOrdDim As OrdinateDimension 
    Dim oFCF As FeatureControlFrame
'---------------------CHANGE THE GENERAL DIMENSIONS
    For Each oGenDim  In oDims.GeneralDimensions             
        oGenDim.Style = oDimStyle
    Next   
'---------------------CHANGE THE ORDINATE DIMENSIONS
    For Each oOrdDim  In oDims.OrdinateDimensions             
        oOrdDim.Style = oDimStyle2
    Next
'---------------------CHANGE THE FEATURE CONTROL FRAMES
    For Each oFCF In oSheet.FeatureControlFrames
        oFCF.Style = oFCFStyle
    Next
'---------------------CHANGE THE HOLE & THREAD SIZE
    Dim oThreadNote As HoleThreadNote
    For Each oThreadNote In oSheet.DrawingNotes.HoleThreadNotes
        oThreadNote.Style = oDimStyle
    Next
Next

End If

'---------------------ACTIVATE SHEET 1
ActiveSheet = ThisDrawing.Sheet("Sheet:1")
'---------------------ZOOM ALL
ThisApplication.ActiveView.Fit
iLogicVb.UpdateWhenDone = True
RuleParametersOutput()    
InventorVb.DocumentUpdate()
ThisDoc.Save

'-------------------END OF iLogic-------------------------------





 

Accepted solutions (1)
1,001 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Here is an additional picture of what areas I want to change on the drawing.

 

Style Help2.jpg

Message 3 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Anonymous,

 

Unfortunately, both ViewAnnotationStyle and DatumTargetStyle are not exposed in Inventor API. You can log this wish list at idea station using following link.

 

https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232/tab/most-recent

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network