Hi @ss13953642009,
Please share the code from the screen shot not able to understand. Apart from this if you want to annotate dimensions automatically on drawing view. you can use the Function "Dimension" which I have pasted below. you can use this method by passing all parameters like the view name, placement of annotation with relative to that view as, Top, Left, Right and Bottom. then third parameter as drawing text position center 0, right- (+Ve numeric), left- (-Ve numeric). fourth and fifth parameter will be the work points name which you created in 3D model to show dimension between two points.
Sub Main()
AddDimension()
End sub
Sub AddDimension()
Trace.TraceInformation("Start Sub AddDimension")
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim oGeneralNotes As GeneralNotes = oSheet.DrawingNotes.GeneralNotes
Dim oTG As TransientGeometry = ThisServer.TransientGeometry
Dim oGenDim As GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions
Trace.TraceInformation("Sub AddDimension - Views")
Dim oView1 As DrawingView = ActiveSheet.View("1").View ' |-----------------------------------|
Dim oView2 As DrawingView = ActiveSheet.View("VIEW2").View '
Dimension(oView1, 3, "Right", 0, "Work Point37", "Work Point57", 0, 0, "")
Dimension(oView1, 3, "Right", 0, "Work Point37", "Work Point36", 0, 0, "")
Dimension(oView1, 3, "Right", 0, "Work Point35", "Work Point57", 0, 0, "") '-----------Like this you can call this method
End Sub
Function Dimension(oView As DrawingView, oView_Offset As Decimal, ViewEdgeName As String, _
oWP_Offset As Decimal, oWP_Name1 As String, oWP_Name2 As String, _
UpperTol As Decimal, LowerTol As Decimal, FormattedText As String)
Try
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oWP1 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item(oWP_Name1)
Dim oWP2 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item(oWP_Name2)
Dim Xpos, Ypos, PPAPdist As Decimal
oView.SetIncludeStatus(oWP1, True)
oView.SetIncludeStatus(oWP2, True)
Dim DimCenterText As Boolean = False
If oWP_Offset = 0 Then DimCenterText = True
For Each oCenterMark In oSheet.Centermarks
If oCenterMark.Attached Then
If oCenterMark.AttachedEntity Is oWP1 Then oCenterMark_1 = oCenterMark
If oCenterMark.AttachedEntity Is oWP2 Then oCenterMark_2 = oCenterMark
End If
Next
'----------------------------------------------------------------------------------------
'For all WorkPoints in assy that ends on a number, adds a CenterMark.
oCenterMark_1.Visible = False
Select Split(oWP_Name1, "_")(Split(oWP_Name1, "_").Count-1)
Case "H1", "H2", "H3", "H4", "H5", "H6","H7", "H8", "H9"
oCenterMark_1.Visible = True
End Select
oCenterMark_2.Visible = False
Select Split(oWP_Name2, "_")(Split(oWP_Name2, "_").Count-1)
Case "H1", "H2", "H3", "H4", "H5", "H6","H7", "H8", "H9"
oCenterMark_2.Visible = True
End Select
'----------------------------------------------------------------------------------------
iLogicVb.UpdateWhenDone = True
WorkPoint_1 = oSheet.CreateGeometryIntent(oCenterMark_1, kPoint2dIntent)
WorkPoint_2 = oSheet.CreateGeometryIntent(oCenterMark_2, kPoint2dIntent)
'In the case of PPAP and not symmetrical tolerance, the measurement distance needs to be increased due to. Inspection Dim Symbol:
If Not UpperTol = 0 And Not LowerTol = 0 And Not UpperTol = LowerTol Then _
PPAPdist = 1.05 Else PPAPdist = 1
'Break()
Select LCase(Left(ViewEdgeName, 3))
Case "top"
PosInX = WorkPoint_2.PointOnSheet.X + oWP_Offset
PosInY = oView.Top + (oView_Offset * PPAPdist) + 0.2
DimensionType = DimensionTypeEnum.kHorizontalDimensionType
Case "bot"
PosInX = WorkPoint_2.PointOnSheet.X + oWP_Offset
PosInY = oView.Top - oView.Height - (oView_Offset * PPAPdist) - 0.2
DimensionType = DimensionTypeEnum.kHorizontalDimensionType
Case "lef"
PosInX = oView.Left - (oView_Offset * PPAPdist) - 0.2
PosInY = WorkPoint_2.PointOnSheet.Y + oWP_Offset
DimensionType = DimensionTypeEnum.kVerticalDimensionType
Case "rig"
PosInX = oView.Left + oView.Width + (oView_Offset * PPAPdist) + 0.2
PosInY = WorkPoint_1.PointOnSheet.Y + oWP_Offset
DimensionType = DimensionTypeEnum.kVerticalDimensionType
Case "par" 'RIGHT SIDE ALIGNED DIMENSION
PosInX = oView.Left + oView.Width + (oView_Offset * PPAPdist) + 0.2
PosInY = WorkPoint_1.PointOnSheet.Y + oWP_Offset
DimensionType = DimensionTypeEnum.kAlignedDimensionType
Case "ang" 'LEFT SIDE ANGLE DIMENSION
PosInX1 = oView.Left - (oView_Offset * PPAPdist) - 0.2
PosInY1 = WorkPoint_2.PointOnSheet.Y + oWP_Offset
DimensionType = DimensionTypeEnum.kAngularDimensionType
End Select
Dim oPointDim As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(PosInX, PosInY)
Dim CreateDimension As GeneralDimension = _
oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPointDim, WorkPoint_1, WorkPoint_2, DimensionType,,)
If Not UpperTol = 0 OrElse Not LowerTol = 0 Then
If UpperTol = LowerTol Then
CreateDimension.Tolerance.SetToSymmetric(UpperTol * 0.1)
Else
CreateDimension.Tolerance.SetToDeviation(UpperTol * 0.1,- LowerTol * 0.1)
End If
End If
Select Left(FormattedText, 5)
Case "Diam:" 'Adds diameter characters before and extra text after dimension.
CreateDimension.Text.FormattedText = Chr(216) & "<DimensionValue/>" & Replace(FormattedText, "Diam:", "")
Case "Equal" 'Adds diameter characters before and extra text after dimension.
CreateDimension.Text.FormattedText = "= " & "<DimensionValue/>" & " = "
Case "Idler" 'Adds diameter characters before and extra text after dimension.
CreateDimension.Text.FormattedText = "= " & "<DimensionValue/>" & " IDLER CC ="
Case "DP" 'Adds diameter characters before and extra text after dimension.
CreateDimension.Text.FormattedText = "= " & "<DimensionValue/>" & " DECK PL ="
Case "CRS" 'Adds diameter characters before and extra text after dimension.
CreateDimension.Text.FormattedText = "= " & "<DimensionValue/>" & " IDLER FIXING CRS ="
Case "ISMC" 'Adds diameter characters before and extra text after dimension.
CreateDimension.Text.FormattedText = "ISMC " & "<DimensionValue/>"
Case "THK." 'Adds diameter characters before and extra text after dimension.
CreateDimension.Precision = 2
CreateDimension.Text.FormattedText = "<DimensionValue/>" & " THK."
Case ""
Exit Select
Case Else 'Add extra text after dimension.
CreateDimension.Text.FormattedText = "<DimensionValue/>" & FormattedText
End Select
Select oWP_Offset
Case 0
CreateDimension.CenterText
Case >0
CreateDimension.Text.HorizontalJustification = kAlignTextRight
Case <0
CreateDimension.Text.HorizontalJustification = kAlignTextRight
End Select
oSheet.Update
Return "-"
Catch ex As Exception
End Try
'---------------------
End Function