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: 

Edit OrdinateDimension with VB.Net

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
GeorgK
546 Views, 5 Replies

Edit OrdinateDimension with VB.Net

Hello all,

how could I edit each ordinate dimension to basic or add for the selected dimension a tolerance? Is it possible to edit each ordinate dimension individually? How could I get the value of the selected dimension?

Thank you

 

Georg

5 REPLIES 5
Message 2 of 6
GeorgK
in reply to: GeorgK
Message 3 of 6
adam.nagy
in reply to: GeorgK

Hi Georg,

 

This could be a way to find the last OrdinateDimension in the set:

Function GetLastDimensionInSet(ByVal ordDimSet As OrdinateDimensionSet) As OrdinateDimension
    Dim ordDim As OrdinateDimension
    Dim max As Double
    For Each ordDim In ordDimSet.Members
        If ordDim.ModelValue > max Then
            max = ordDim.ModelValue
            Set GetLastDimensionInSet = ordDim
        End If
    Next
End Function

In order to get more information about the selection you could subscribe to the OnSelect event of UserInputEvents. This way you could get the model position of the selection which would help you identify the selected dimension:

Function GetClosestDimensionInSet(ByVal ordDimSet As OrdinateDimensionSet, ByVal pt As Point2d) As OrdinateDimension
    Dim tr As TransientGeometry
    Set tr = ThisApplication.TransientGeometry
    
    Dim ordDim As OrdinateDimension
    Dim min As Double
    min = 1000000
    For Each ordDim In ordDimSet.Members
        Dim poly As Polyline2d
        Set poly = ordDim.DimensionLine
        
        Dim i As Integer
        For i = 1 To poly.PointCount - 1
            Dim line As LineSegment2d
            Set line = tr.CreateLineSegment2d(poly.PointAtIndex(i), poly.PointAtIndex(i + 1))
        
            If line.DistanceTo(pt) < min Then
                min = line.DistanceTo(pt)
                Set GetClosestDimensionInSet = ordDim
            End If
        Next
    Next
End Function

Inside OnSelect you could use it like this:

Private Sub uiEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, MoreSelectedEntities As ObjectCollection, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)
    Dim tr As TransientGeometry
    Set tr = ThisApplication.TransientGeometry
    
    Dim ordDim As OrdinateDimension
    Set ordDim = GetClosestDimensionInSet(JustSelectedEntities(1).OrdinateDimensionSet, tr.CreatePoint2d(ModelPosition.X, ModelPosition.Y))
    
    ordDim.Text.FormattedText = ordDim.Text.FormattedText + "+"
End Sub

Cheers,



Adam Nagy
Autodesk Platform Services
Message 4 of 6
GeorgK
in reply to: adam.nagy

Hello Adam,

 

after a long time I found the time to try your code. The event of UserInputEvents works. But it works only with a "try catch".

 

Thank you Georg

Message 5 of 6
GeorgK
in reply to: GeorgK

Hello Adam,

 

is it possible to add the function to the menu?

 

Thank you Georg

 

 

Message 6 of 6
adam.nagy
in reply to: GeorgK

Hi Georg,

 

Have a look at this: http://modthemachine.typepad.com/my_weblog/2012/03/customizing-marking-menus.html

You can add your own custom items and they can do whatever you want.

 

Concernig try/catch. The code is only working if you select the specific type of objects. 
If you select something else, it would throw an error.

 

Cheers,



Adam Nagy
Autodesk Platform Services

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

Post to forums  

Autodesk Design & Make Report