Creating Dimensions on Flat Pattern using WorkPoints

Creating Dimensions on Flat Pattern using WorkPoints

J_PO
Explorer Explorer
1,180 Views
8 Replies
Message 1 of 9

Creating Dimensions on Flat Pattern using WorkPoints

J_PO
Explorer
Explorer

Hello all,

 

I have thought myself to create automated models and drawings thanks to this amazing forum but now i have run into a problem which seems like it hasn't come up yet. I am trying to create a dimension between two points on a Flat Pattern (examle in the added screencap) using WorkPoints from the folded model, since it doesn't seem to work at all with WorkPoints from the Flat Pattern. Below is the code that i am trying to use. In red is the SetIncludeStatus which is the line where the problems seem to be.

 

Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim oView As DrawingView = ActiveSheet.View("VIEW1").View
Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument


Dim oGeomIntent01 As Inventor.GeometryIntent
Dim oWP01 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP_1")
oView.SetIncludeStatus(oWP01, True)
Dim oCenterMark01 As Inventor.Centermark
oCenterMark01 = oSheet.Centermarks.AddByWorkFeature(oWP01, oView)
oGeomIntent01 = oSheet.CreateGeometryIntent(oCenterMark01, kPoint2dIntent)
oCenterMark01.Visible = False

Dim oGeomIntent02 As Inventor.GeometryIntent
Dim oWP02 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP_2")
oView.SetIncludeStatus(oWP02, True)
Dim oCenterMark02 As Inventor.Centermark
oCenterMark02 = oSheet.Centermarks.AddByWorkFeature(oWP02, oView)
oGeomIntent02 = oSheet.CreateGeometryIntent(oCenterMark02, kPoint2dIntent)
oCenterMark02.Visible = False

Dim textPoint As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(oView.Left + (oView.Width) + 1, oView.Top - (oView.Width / 2))
Dim oDim As GeneralDimension
oDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint, oGeomIntent01, oGeomIntent02, DimensionTypeEnum.kHorizontalDimensionType)

Without the WorkPoints included in the View I cannot create my dimension.

I have tried using Workplanes and the edges by using attributes but I cannot get this to work either.

The only way I have been able to make this work is by using a view of the folded model which is not ideal.

Does anyone know how to create a dimension from points on a Flat Pattern?

 

Thank you in advance,

Jeffrey

 

 

 

0 Likes
Accepted solutions (1)
1,181 Views
8 Replies
Replies (8)
Message 2 of 9

YuhanZhang
Autodesk
Autodesk
Accepted solution

You can't do this from UI or API, because the work points(Onder and Boven) are belong to the folded model, but your drawing view is bases on the flat pattern, so you can't create center marks from them.  From your code seems your purpose is to create a linear dimension for the two vertices where the two work points located to, so why not you just create the linear dimension on the two vertices in flat pattern? You can try below iLogic rule to do this:

 

Sub Main()
Dim oDrawing As DrawingDocument
oDrawing = ThisDoc.Document 

Dim oSheet As Sheet
 oSheet = oDrawing.ActiveSheet
 
Dim oView As DrawingView
 oView = oSheet.DrawingViews(1)

Dim oGeomIntent01 As Inventor.GeometryIntent
 oGeomIntent01 = oSheet.CreateGeometryIntent(oView.DrawingCurves.Item(1), PointIntentEnum.kEndPointIntent)

Dim oGeomIntent02 As Inventor.GeometryIntent
 oGeomIntent02 = oSheet.CreateGeometryIntent(oView.DrawingCurves.Item(2), PointIntentEnum.kStartPointIntent)

Dim textPoint As Inventor.Point2d
 textPoint = ThisApplication.TransientGeometry.CreatePoint2d(oView.Left + (oView.Width) + 1, oView.Top - (oView.Height / 2))
Dim odim As GeneralDimension
 odim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint, oGeomIntent01, oGeomIntent02, DimensionTypeEnum.kVerticalDimensionType)

End Sub

Dim.png

 

Hope above helps.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 9

J_PO
Explorer
Explorer

That works great, thank you very much.

I was not aware of the possibility to use the start or endpoint of a drawingcurve, this will help me a lot in the future.

0 Likes
Message 4 of 9

mseveroLXMQ8
Participant
Participant

I have a similar problem, but I need to get a dimension form an edge to a hole. What should I change in the code to do that?

 

Thanks

0 Likes
Message 5 of 9

punam_bansode
Contributor
Contributor

HI @YuhanZhang ,

Thanks for this solution. I tried with this option but each and every time its index numbers are changing whenever there is any parameter changes accordingly geometry changing and then Index numbers are also getting changed. is there any option to get the geometry intent from its model space instead of its indexing number.

 

Thank You.

0 Likes
Message 6 of 9

YuhanZhang
Autodesk
Autodesk

@punam_bansode Yes, if you know the model geometry(Edge or Face) that the drawing curve is projected, you can use get the drawing curve by specifying the model geometry to DrawingView.DrawingCurves(ModelObject), see help page below:

 

Inventor 2026 Help | DrawingView.DrawingCurves Property | Autodesk



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 7 of 9

JMGunner
Enthusiast
Enthusiast

@J_PO 

 

How too get workpoint from FlatPattern

you need too get SheetMetalComponentDefinition and  Dim fp As FlatPattern

 

function  1 send (Flat Pattern.WorkPoint1) 

or (WorkPoint)

 

 

Best JMG

 

 Function CreateWorkPointCenterMarksIfInTopLevel(entity1 As String, oSheet As Sheet, oView As DrawingView, oDoc As Inventor.Document) As Inventor.GeometryIntent
     Dim oWP1 As Inventor.WorkPoint
     If entity1.Contains("Flat Pattern") = False Then
     Try
         Dim pDoc As PartDocument = oDoc
         Dim pCompDef As PartComponentDefinition  = pDoc.ComponentDefinition 
        oWP1 = pCompDef.WorkPoints.Item(entity1)
Catch
        Dim aDoc As AssemblyDocument = oDoc
       Dim aCompDef As AssemblyComponentDefinition  = aDoc.ComponentDefinition 
      oWP1 = aCompDef.WorkPoints.Item(entity1)
End Try
Else
       Dim smDoc As PartDocument = oDoc
       Dim smCompDef As SheetMetalComponentDefinition = smDoc.ComponentDefinition
       Dim fp As FlatPattern = smCompDef.FlatPattern
       Dim smArray() As String = entity1.Split(".")
       oWP1 = fp.WorkPoints.Item(smArray(1))
End If
 
Try
     oView.SetIncludeStatus(oWP1, True)
Catch
 
End Try
    Dim oCenterMark1 As Inventor.Centermark
    Dim oCenterMark As Inventor.Centermark
 
 
For Each oCenterMark In oSheet.Centermarks
If oCenterMark.Attached Then
  If oCenterMark.AttachedEntity Is oWP1 And ifCenterMarkIsInsideViewBorder(oCenterMark, oView) = True Then
   oCenterMark1 = oCenterMark
  End If
End If
Next
 
Dim oGeomIntent1 As Inventor.GeometryIntent
 
oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, kPoint2dIntent)
 
oCenterMark1.Visible = False
Return oGeomIntent1
End Function

 

 

0 Likes
Message 8 of 9

punam_bansode
Contributor
Contributor

Hello @JMGunner , 

 

B

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

y reading your code I am assuming that I need to create workpoints on flat pattern model then that points are going to access through this function. I will try this code. I want to access those workpoints to add linear dimensions in drawing view and for this I need two workpoint name as string for each dimension. I have created one dimension method for 3d model with the same approach, but I am not able to get flat pattern member access from that. I will share the code below. Please tell me if you can add some lines for flat pattern access. Thank you so much for your response. 

0 Likes
Message 9 of 9

JMGunner
Enthusiast
Enthusiast
 Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
  Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
DIm oView As DrawingView 
 
Dim WorkPoint_1 As Inventor.GeometryIntent
 
 
WP_Name1 = "Flat Pattern.Work Point1"
WorkPoint_1= CreateWorkPointCenterMarksIfInTopLevel(oWP_Name1 , oSheet, oView , oDoc)
 
Dim CreateDimension As GeneralDimension = _
			oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPointDim, WorkPoint_1, WorkPoint_2, DimensionType,,)
 
Best JM Gunnar
0 Likes