Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Isolating Dimension Type using iLogic

2 REPLIES 2
Reply
Message 1 of 3
djbrown
630 Views, 2 Replies

Isolating Dimension Type using iLogic

I have an iLogic rule that converts certain dimensions from a fractional dimension to a sheet steel gage.  It is looping through all the General Dimensions on the drawing.  This causes some of my angular dimensions to be updated by mistake, so I need it to exclude all angular dimensions when it runs through the loop and can't find how to do it. 

 

The code is given below if that is of any assistance.

 

 
Dim oDoc as DrawingDocument
Dim tDim as String
oDoc = ThisApplication.ActiveDocument
Dim sheetX As Sheet = oDoc.Sheets(1)
For Each genDim as GeneralDimension In sheetX.DrawingDimensions.GeneralDimensions 
   tDim = gendim.text.formattedtext
   If (Len(tDim) > 25) Then Goto 30:
   gendim.hidevalue = False
   genFrac = (RoundToFraction(genDim.modelvalue/2.54,1/64,RoundingMethod.Round))
   If (genFrac = "3/16" Or genFrac = "1/8" Or genFrac = "1/16" Or genFrac = "3/64") Then
      If (Right(iProperties.Value("Custom","Material Thickness"),3) = "ga.") Then
         genDim.hidevalue = True
	     gendim.text.formattedtext = iProperties.Value("Custom","Material Thickness")
	  Else
	     gendim.text.formattedtext = ""
	  End If
   End If
30: Next 

 

Thanks,

 

Dan

2 REPLIES 2
Message 2 of 3
RodrigoEiras
in reply to: djbrown

Here you can find a piece of code I use to look for angular an linear dimensions and center them. It can be useful for you as an example where linear and angular dimensions are identified. You can use it to modify only the linear dimensions.

 

SyntaxEditor Code Snippet

'Centre and arrange dimensions


    Dim oDoc As DrawingDocument
    oDoc = ThisApplication.ActiveDocument

     Dim oSheet As Sheet
    oSheet = oDoc.ActiveSheet

    Dim oDrawingDim As DrawingDimension
    Dim oDrawingDims As DrawingDimensions
    Dim oDimsToBeArranged As ObjectCollection
    
    Dim iLinearDimCount As Integer
    Dim iAngularDimCount As Integer
    Dim iOtherDimCount As Integer
    iLinearDimCount = 0
    iAngularDimCount = 0
    iOtherDimCount = 0
    
    ' Iterate over all dimensions in the drawing and
    ' center them if they are linear or angular.
    ' Add them to the ObjectCollection to be arranged

    oDrawingDimensions = oSheet.DrawingDimensions

    oDimsToBeArranged = ThisApplication.TransientObjects.CreateObjectCollection
    
    For Each oDrawingDim In oDrawingDimensions
        Select Case oDrawingDim.Type
            Case 117474560    ' kLinearGeneralDimensionObject
                oDrawingDim.CenterText
                   oDimsToBeArranged.Add(oDrawingDim)
                iLinearDimCount = iLinearDimCount+1
            Case 117474816 'kAngularGeneralDimensionObject
                oDrawingDim.CenterText
                   oDimsToBeArranged.Add(oDrawingDim)
                iAngularDimCount = iAngularDimCount+1
            Case Else
                iOtherDimCount = iOtherDimCount +1
        End Select        
    Next
    
    
    Trace.Writeline("Linear dimensions = "& iLinearDimCount)
    Trace.Writeline("Angular dimensions = "& iAngularDimCount)
    Trace.Writeline("Other dimensions = "& iOtherDimCount)

    oDrawingDimensions.Arrange(oDimsToBeArranged)
Message 3 of 3

holethreadnote = 72194

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report