Center dimension text

Center dimension text

anavazquez5LRNJ
Enthusiast Enthusiast
185 Views
1 Reply
Message 1 of 2

Center dimension text

anavazquez5LRNJ
Enthusiast
Enthusiast

Hello, everyone, I am working with automated drawings, but I'm getting stuck because I can't get the dimensions right, every time I run the rule, they appear like this, I tried centering the dimensions with another code, but it doesn't center some dimensions.

 

anavazquez5LRNJ_0-1708985851721.png

And I would like it to be displayed like this

anavazquez5LRNJ_1-1708986001834.png

 


have any of you been able to solve this problem by coding, this is how I generate the dimension.

If iProperties.Value("Custom", "NominalFrameWidth") < 57.5 Then
	WSub = 0
Else If iProperties.Value("Custom", "NominalFrameWidth") < 69 Then
	WSub = .1
Else If iProperties.Value("Custom", "NominalFrameWidth") < 80.5 Then
	WSub = 3
Else If iProperties.Value("Custom", "NominalFrameWidth") < 92 Then
	WSub = 3.5
Else If iProperties.Value("Custom", "NominalFrameWidth") < 103.5 Then
	WSub = 3.8
Else If iProperties.Value("Custom", "NominalFrameWidth") < 115 Then
	WSub = .5
Else If iProperties.Value("Custom", "NominalFrameWidth") < 120 Then
	WSub = 4
End If


Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
        Dim oView As DrawingView = ActiveSheet.View("VIEW3").View
        Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
        
        Dim oGeomIntent1 As Inventor.GeometryIntent
        Dim oGeomIntent2 As Inventor.GeometryIntent
		Dim oGeomIntent3 As Inventor.GeometryIntent
		Dim oGeomIntent4 As Inventor.GeometryIntent
		Dim oGeomIntent5 As Inventor.GeometryIntent
		Dim oGeomIntent6 As Inventor.GeometryIntent

        Dim oWP1 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP_Lock_Width_End_3")
        Dim oWP2 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP_Lock_Width_1")
		Dim oWP3 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP_Lock_Width_2")
		Dim oWP4 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP_Lock_Width_End_4")
        
        oView.SetIncludeStatus(oWP1, True)
        oView.SetIncludeStatus(oWP2, True)
		oView.SetIncludeStatus(oWP3, True)
		oView.SetIncludeStatus(oWP4, True)

        Dim oCenterMark1 As Inventor.Centermark
        Dim oCenterMark2 As Inventor.Centermark
		Dim oCenterMark3 As Inventor.Centermark
		Dim oCenterMark4 As Inventor.Centermark
        Dim oCenterMark As Inventor.Centermark

        For Each oCenterMark In oSheet.Centermarks

            If oCenterMark.Attached Then
                If oCenterMark.AttachedEntity Is oWP1 Then
                    oCenterMark1 = oCenterMark
                End If
                If oCenterMark.AttachedEntity Is oWP2 Then
                    oCenterMark2 = oCenterMark
                End If
				 If oCenterMark.AttachedEntity Is oWP3 Then
                    oCenterMark3 = oCenterMark
                End If
				 If oCenterMark.AttachedEntity Is oWP4 Then
                    oCenterMark4 = oCenterMark
                End If
            End If
        Next
        
        oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, kPoint2dIntent)
        oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, kPoint2dIntent)
		oGeomIntent3 = oSheet.CreateGeometryIntent(oCenterMark3, kPoint2dIntent)
		oGeomIntent4 = oSheet.CreateGeometryIntent(oCenterMark4, kPoint2dIntent)

        oCenterMark1.Visible = False
        oCenterMark2.Visible = False
		oCenterMark3.Visible = False
		oCenterMark4.Visible = False
        
        Dim textPoint As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(15.5 - WSub,14)
        Dim oDim As GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint, oGeomIntent1, oGeomIntent2, DimensionTypeEnum.kHorizontalDimensionType)
        Dim textPoint1 As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(13 - WSub,13.5)
        Dim oDim1 As GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint1, oGeomIntent2, oGeomIntent3, DimensionTypeEnum.kHorizontalDimensionType)
		Dim textPoint2 As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(10.2 - WSub,14)
        Dim oDim2 As GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint2, oGeomIntent3, oGeomIntent4, DimensionTypeEnum.kHorizontalDimensionType)

 

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

J-Camper
Advisor
Advisor

@anavazquez5LRNJ,

 

GeneralDimensions have a boolean property for that:

Dim MyGeneralDimension As GeneralDimension = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Select a GeneralDimension")
If MyGeneralDimension Is Nothing Then Exit Sub
MyGeneralDimension.ArrowheadsInside = False

 

As long as you originally placed the dimension at the center, I think it should re-center itself, like changing the property from the UI.  If not you would need to move the center point back after the boolean property is set to False.