Changing precision of baselineset members causes Inventor to crash

Changing precision of baselineset members causes Inventor to crash

COLINBRUSCHI
Enthusiast Enthusiast
323 Views
1 Reply
Message 1 of 2

Changing precision of baselineset members causes Inventor to crash

COLINBRUSCHI
Enthusiast
Enthusiast

Hi All,

 

This simple code causes inventor to crash when changing the precision of a BLset member, other than the origin member. Weirdly, saving the IDW, closing & re-opening allows the members' precision to be altered.

 

A new BLset is created from the intents, 2dpoint and dimensiontype of an existing non-BLset member. Other non-BLset dimensions are then added to the newly created BLset. This BLset is created no problems, and it's precision/tolerance type can be changed no problem. Once the other members are added, changing their precision/tolerance causes a crash, but not after saving/re-opening. Any thoughts?

 

 

Dim oDoc As DrawingDocument = g_inventorApplication.ActiveDocument
Dim newBaselineset As BaselineDimensionSet
Dim oIntent1 As GeometryIntent  'first geometry intent of the selection
Dim oIntent2 As GeometryIntent  'Second geometry intent of the selection
Dim mSelection As DrawingDimension
Dim dimHighlightSet As HighlightSet = oDoc.CreateHighlightSet
Dim userSelection As New List(Of LinearGeneralDimension)
Dim oCommandMgr As CommandManager = g_inventorApplication.CommandManager
Dim oSheet As Sheet = oDoc.ActiveSheet

While True

mSelection = oCommandMgr.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Select members starting from origin, ESC to continue")

System.Windows.Forms.Application.DoEvents()     '''''   This code prevents a commandmanager.pick bug 
System.Threading.Thread.Sleep(50)              '''''   causing problems when user presses
System.Windows.Forms.Application.DoEvents()     '''''   ESC to end command

If mSelection Is Nothing Then
  Exit While
End If

If mSelection.Type = ObjectTypeEnum.kLinearGeneralDimensionObject Then
userSelection.Add(mSelection)
dimHighlightSet.AddItem(mSelection)
Else
MsgBox("Invalid Selection", vbOKOnly + vbExclamation)
End If

End While

If userSelection.Count = 0 Then
  Exit Sub
End If

 Dim i = 1

For Each oDimension As LinearGeneralDimension In userSelection

If i = 1 Then

Dim intents As ObjectCollection = g_inventorApplication.TransientObjects.CreateObjectCollection()
oIntent1 = oSheet.CreateGeometryIntent(oDimension.IntentOne.Geometry)
oIntent2 = oSheet.CreateGeometryIntent(oDimension.IntentTwo.Geometry)

Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oPosition As Point2d = oDimension.Text.Origin
Dim oPoint As Point2d = oTG.CreatePoint2d(oPosition.X, oPosition.Y)

newBaselineset = oSheet.DrawingDimensions.BaselineDimensionSets.Add(intents, oPoint, oDimension.DimensionType)

If oDimension.Tolerance.ToleranceType = ToleranceTypeEnum.kDeviationTolerance Then
 newBaselineset.Members(1).Tolerance.SetToDeviation(oDimension.Tolerance.Upper, oDimension.Tolerance.Lower)
ElseIf oDimension.Tolerance.ToleranceType = ToleranceTypeEnum.kSymmetricTolerance Then
                    newBaselineset.Members(1).Tolerance.SetToSymmetric(oDimension.Tolerance.Upper)
ElseIf oDimension.Tolerance.ToleranceType = ToleranceTypeEnum.kReferenceTolerance Then
newBaselineset.Members(1).Tolerance.SetToReference()
ElseIf oDimension.Tolerance.ToleranceType = ToleranceTypeEnum.kLimitsFitsShowTolerance Then
                    newBaselineset.Members(1).Tolerance.SetToFits(ToleranceTypeEnum.kLimitsFitsShowTolerance, oDimension.Tolerance.HoleTolerance, oDimension.Tolerance.ShaftTolerance)
End If

newBaselineset.Members(1).Precision = oDimension.Precision
newBaselineset.Members(1).TolerancePrecision = oDimension.TolerancePrecision

                oDimension.Delete()

                i = i + 1

Else
Try

newBaselineset.AddMember(oDimension)
newBaselineset.Members(i).Precision = 2
i=i+1
                Catch
                End Try
            End If
        Next

 

 

0 Likes
324 Views
1 Reply
Reply (1)
Message 2 of 2

COLINBRUSCHI
Enthusiast
Enthusiast

Well I've spent a good few hours on this. It appears the only way to avoid the crash is to create the baselinedimensionset with all the intents of all the dimensions in the user's selection, rather than just creating with the first member's intents and then adding the other members with the .addmember method...

0 Likes