Assembly level modification stopping drawing curves being returned.

Assembly level modification stopping drawing curves being returned.

A.Acheson
Mentor Mentor
1,208 Views
12 Replies
Message 1 of 13

Assembly level modification stopping drawing curves being returned.

A.Acheson
Mentor
Mentor

Hi All, having trouble finding out what is going on here. The below snippets of a larger code that use the proxy face of a part and returns the drawing curves in the view. That works great. It does not return any drawing curves if there is an assembly level modification like a hole on the occurrence no matter which face it is on.. Any ideas?

AAcheson_0-1696631521382.png

 

 

 

 

 

	Try
	   occ.CreateGeometryProxy(partface, partFaceProxy)
	   drawViewCurves = drawView.DrawingCurves(partFaceProxy)
	   Logger.Info("Drawcurvecount" & drawViewCurves.Count)
	Catch
	    Logger.Info("Error curve count")
	End Try

 

 

Test Code here. With hole on occurrence, curve count is zero , delete the hole and curve count goes to 4. So it must be a different face but how to detect this face and it's drawing curves in the drawing?

AAcheson_0-1696635692181.png

 

 

 

	Dim curve1 As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing view").Parent					
	modelGeom = curve1.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence
	
	MessageBox.Show(occ.Name, "Title")
	
	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities

	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity("Face0")
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces
		
		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
	   			occ.CreateGeometryProxy(namedFace, partFaceProxy)
	   			drawViewCurves = curve1.Parent.DrawingCurves(partFaceProxy)
	   			Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
			Catch
	    		Logger.Info("Error curve count")
			End Try

		End If
	Next

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Accepted solutions (4)
1,209 Views
12 Replies
Replies (12)
Message 2 of 13

Michael.Navara
Advisor
Advisor

This is really hard task. I'm not sure if there is a better solution, but this is my approach. It is not elegant but works.

This code:

  • requires the source model open.
  • may fail if the modification of face is near the PointOnFace
  • doesn't work on InventorServer (APS Design Automation (Forge))
  • and I don't know what more...
Sub Main
	Dim curve1 As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing view").Parent
	modelGeom = curve1.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence

	MessageBox.Show(occ.Name, "Title")

	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities

	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity("Face0")
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces

		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
				'occ.CreateGeometryProxy(namedFace, partFaceProxy)
				partFaceProxy = GetModifiedFaceProxy(occ, namedFace)
				drawViewCurves = curve1.Parent.DrawingCurves(partFaceProxy)
				Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
			Catch
				Logger.Info("Error curve count")
			End Try

		End If
	Next
End Sub

Function GetModifiedFaceProxy(occ As ComponentOccurrence, namedFace As Face) As FaceProxy

	Dim asmDef As AssemblyComponentDefinition = occ.ContextDefinition
	Dim asm As Document = asmDef.Document
	If asm.Views.Count = 0 Then
		If MsgBox("Assembly must be visible! Open?", MsgBoxStyle.YesNo + MsgBoxStyle.Question) <> MsgBoxResult.Yes Then
			Return Nothing
		End If
		Dim currentView = ThisApplication.ActiveView
		asm.Views.Add()
		currentView.Activate()
	End If

	'Get namedFace proxy represenation
	Dim partFaceProxy As FaceProxy
	occ.CreateGeometryProxy(namedFace, partFaceProxy)

	'Get point on face proxy
	Dim ptOnFace As Point = partFaceProxy.PointOnFace
	
	'Find all faces near this point
	Dim filters As SelectionFilterEnum() = {SelectionFilterEnum.kPartFaceFilter }
	Dim nearFaces = asmDef.FindUsingPoint(ptOnFace, filters, 0.001)

	'Check if the source of found face is the namedFace
	For Each nearFace As FaceProxy In nearFaces
		Dim nearSourceFace As Face = nearFace.GetSourceFace(True)
		If nearSourceFace Is namedFace Then
			logger.Debug("found")
			Return nearFace
		End If
	Next
	Logger.Debug("not found")
	Return Nothing

End Function

 

Message 3 of 13

A.Acheson
Mentor
Mentor

Thanks Michael, I will need to test your method on my end. It sounds like your doing

 an auto select of the faces within the model closes to the point on the original named face. 

 

Another avenue I haven't tested is to get the surfacebodies from the assembly ComponentDefinition and test the faces and it's reference entities.

Syntax

AssemblyComponentDefinition.SurfaceBodies() As SurfaceBodies

Syntax

Face.ReferencedEntity() As Object

Description

Property that returns the referenced face(s) from the source part. This could be a proxy object in case of a derived assembly. The property returns Nothing if there isn't a referenced entity.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 13

Michael.Navara
Advisor
Advisor
Accepted solution

Another approach is to iterate all faces in occurrence surface bodies. It needs to be tested the performance in case when the part is not simple as in your test data set. It can spent a time when the part has hundreds or thousands of faces.

 

Function GetModifiedFaceProxy2(occ As ComponentOccurrence, namedFace As Face) As FaceProxy

	For Each occBody As SurfaceBody In occ.SurfaceBodies
		For Each occFace As Face In occBody.Faces
			Dim partFace As Face = occFace.GetSourceFace(True)
			If occSourceFace Is namedFace Then
				Logger.Debug("found")
				Return occFace
			End If
		Next
		Logger.Debug("not found")
		Return Nothing
	Next
End Function

 

Message 5 of 13

WCrihfield
Mentor
Mentor

You could try inspecting the faces of the HoleFeature in the assembly too, just to narrow down the search a bit further.  The face you are looking for may not be directly included within the HoleFeature.EndFaces, HoleFeature.SideFaces, or HoleFeature.Faces collections, but should be attached directly to its side face(s).  Funny thing about faces is that the face seems to loose its identity when a feature changes it.  And since this feature is within the context of the main assembly, stepping up to the proxy face of a lower level face will likely no longer work properly.  It would be nice if there were some sort of ancestry that was kept in tact when a feature changes a face, so that we can backwards trace what the previous identity of a face was before a feature changed it.  You could try to obtain the face that was used to create the HoleFeature, and that face may match your proxy one, even though the resulting face after the feature is likely different, as long as the face was not effected by more than just that one feature along the way.  Just thinking through the keyboard, because I could not use the attached ZIP file (corporate security policy / restrictions).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 13

A.Acheson
Mentor
Mentor

Hi Michael,

Your first attempt here seems to work albeit with still some missing faces now where the hole passes through.  Really appreciate the help here thankyou. Instead of returning all the faces I looked just at the face closes to the point.

 

Return nearFaces.Item(1)

 

Weirdly enough going back to my initial attempt, if I do a SelectSet on the the origional proxy face based off the part occurrence that is being selected within the assembly the correct face is selected within the model but there isn't any curves to return in the drawing. I am wondering is the proxy face been created in the right context? Should it be in the context of the sub assembly ?  

 

occ.CreateGeometryProxy(namedFace, partFaceProxy)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 13

WCrihfield
Mentor
Mentor

Another thought that crossed my mind about this situation is that, if you are 'picking' a curve in a drawing view that is part of the profile of that face, and that face is of a component in an assembly, then the DrawingCurveSegment.Parent.ModelGeometry should be an EdgeProxy type object.  That EdgeProxy will already be in the context of the main assembly, so if you accessed its EdgeProxy.Faces property, you should get a Faces object which contains the FaceProxy objects of that component that are also in the context of the main assembly.  And in simple scenarios, there are often only 2 faces associated with an edge.  Similar situation with the EdgeProxy.Parent property, which is supposed to return a SurfaceBody type object, but in this case it should return the SurfaceBodyProxy type object that should also still be in the context of the main assembly.  Just thought I would put that idea out there as food for thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 13

A.Acheson
Mentor
Mentor

Thanks for the additional thoughts, it is crazy how much extra work is needed. I haven't tried the hold End and start faces yet this would be my next try as well. @MjDeck ,

@JhoelForshav, @JelteDeJong 

Would you guys have any thoughts on a robust approach to this? The proxy face is correctly found in the model space but how to translate that in to drawing curves in the drawing space? 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 9 of 13

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @A.Acheson 

I'd probably use this approach:

 

check if occ has body ovverides.

If so:

check the faces in the occs surfacebodies and find the one that has its sourceface equal to namedFace.

Else

create the proxy from namedface.

 

Example (could probably be shortened using lambda expressions):

 

 

	Dim curve1 As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing view").Parent					
	modelGeom = curve1.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence
	
	MessageBox.Show(occ.Name, "Title")
	
	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities

	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity("Face0")
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces
		
		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
				If occ.HasBodyOverride
					For Each oSurfBod As SurfaceBody In occ.SurfaceBodies
						For Each oFace As Face In oSurfBod.Faces
							If oFace.GetSourceFace Is namedFace Then partFaceProxy = oFace
							Exit For
						Next
						If partFaceProxy IsNot Nothing Then Exit For
					Next
				Else
					occ.CreateGeometryProxy(namedFace, partFaceProxy)
				End If
				
	   			drawViewCurves = curve1.Parent.DrawingCurves(partFaceProxy)
	   			Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
			Catch
	    		Logger.Info("Error curve count")
			End Try

		End If
	Next

 

EDIT: Sorry, I saw now that @Michael.Navara already had suggested basically the same thing...

 

Message 10 of 13

A.Acheson
Mentor
Mentor

Thanks Jhoel,

I believe I have gone over this in previous attempts with no luck. See below sample. It works perfect with no assembly hole and or with hole and manually picked curves. With the autoselect via named face the Curves are being returned at the same position x  but I am unable to get an intent I believe to place the dimension.

AAcheson_0-1697044295808.png

 

 

Sub Main
	
	Dim curve As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing segment").Parent					
	modelGeom = curve.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence
	Dim drawView As DrawingView = curve.Parent
	Dim drawSheet As Sheet = drawView.Parent

	MessageBox.Show(occ.Name, "Title")
	Dim curve1 As DrawingCurve = Nothing
	Dim curve2 As DrawingCurve = Nothing
	'Get curve, location of each dimension leg start point.
	curve1 = GetCurve("Face0", occ, drawView)
	'curve1  = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing Segment").Parent	
	
	'curve2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing Segment").Parent	
	curve2  = GetCurve("Face1", occ, drawView)
	
	MessageBox.Show(curve1.StartPoint.X, "curve1.StartPoint.X")
	MessageBox.Show(curve2.StartPoint.X, "curve2.StartPoint.X")
	
	Dim tg As TransientGeometry = ThisApplication.TransientGeometry

	Dim pt1 As Point2d = tg.CreatePoint2d(curve1.StartPoint.X + 2, curve1.StartPoint.Y)

	Dim genDims As GeneralDimensions = drawSheet.DrawingDimensions.GeneralDimensions

	Dim dim1 As LinearGeneralDimension = genDims.AddLinear(pt1, drawSheet.CreateGeometryIntent(curve1), drawSheet.CreateGeometryIntent(curve2))
	dim1.CenterText
	
End Sub

Function  GetCurve(faceName As String, occ As ComponentOccurrence, drawView As DrawingView) As DrawingCurve
	
	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities

	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity(faceName)
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces
		
		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
				If occ.HasBodyOverride
					For Each oSurfBod As SurfaceBody In occ.SurfaceBodies
						For Each oFace As Face In oSurfBod.Faces
							If oFace.GetSourceFace Is namedFace Then partFaceProxy = oFace
							Exit For
						Next
						If partFaceProxy IsNot Nothing Then Exit For
					Next
				Else
					occ.CreateGeometryProxy(namedFace, partFaceProxy)
				End If
				
	   			drawViewCurves = drawView.DrawingCurves(partFaceProxy)
	   			Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
				Return drawViewCurves(1)
			Catch
	    		Logger.Info("Error curve count")
			End Try

		End If
	Next
	
End Function

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 11 of 13

MjDeck
Autodesk
Autodesk
Accepted solution

Hi Alan - here's a version of your rule that will work with the assembly feature. I made a few changes, but I think the only one that is required is to fix the logic in the loop that finds the source face:

If oFace.GetSourceFace Is namedFace Then 
	Logger.Info(" --- found source face")
	partFaceProxy = oFace
	Exit For
End If

(Another change I made was to the particular face names. If you try this rule as is, please check the face names.)

The iLogic GetIntent function can find the drawing curves in this case, but only for named edges. Faces won't work. Thanks for posting this code. We might be able to use it to improve the iLogic function.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 12 of 13

JhoelForshav
Mentor
Mentor

Hi @A.Acheson 

Using your testfiles, when you get the curves of the face with a hole in it, the circle curve representing the hole is also in that collection. In this case, that curve is in the first position so the reason the code crashes there is that you're getting a circle curve as curve1 and a circle curve doesn't have a start point.

 

See my comments in the code:

Sub Main
	
	Dim curve As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing segment").Parent					
	modelGeom = curve.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence
	Dim drawView As DrawingView = curve.Parent
	Dim drawSheet As Sheet = drawView.Parent

	MessageBox.Show(occ.Name, "Title")
	Dim curve1 As DrawingCurve = Nothing
	Dim curve2 As DrawingCurve = Nothing

	curve1 = GetCurve("Face0", occ, drawView)
	'this will tell you the curve type:
	MsgBox([Enum].GetName(GetType(Inventor.CurveTypeEnum), curve1.CurveType))
	'curve1 is the circle curve, doesn't have a StartPoint.
	'It does however have a center point:
	MsgBox("curve1 center point" & vbCrLf & curve1.CenterPoint.X & ";" & curve1.CenterPoint.Y)
	
	'curve2 doesn't work because theres no entity named "Face1"
	curve2 = GetCurve("Face1", occ, drawView)
	'therefore its nothing:
	If curve2 Is Nothing Then MsgBox("curve2 is nothing")

	
'	Dim tg As TransientGeometry = ThisApplication.TransientGeometry

'	Dim pt1 As Point2d = tg.CreatePoint2d(curve1.StartPoint.X + 2, curve1.StartPoint.Y)

'	Dim genDims As GeneralDimensions = drawSheet.DrawingDimensions.GeneralDimensions

'	Dim dim1 As LinearGeneralDimension = genDims.AddLinear(pt1, drawSheet.CreateGeometryIntent(curve1), drawSheet.CreateGeometryIntent(curve2))
'	dim1.CenterText
	
End Sub

Function  GetCurve(faceName As String, occ As ComponentOccurrence, drawView As DrawingView) As DrawingCurve
	
	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities

	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity(faceName)
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces
		
		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
				If occ.HasBodyOverride
					For Each oSurfBod As SurfaceBody In occ.SurfaceBodies
						For Each oFace As Face In oSurfBod.Faces
							If oFace.GetSourceFace Is namedFace Then partFaceProxy = oFace
							Exit For
						Next
						If partFaceProxy IsNot Nothing Then Exit For
					Next
				Else
					occ.CreateGeometryProxy(namedFace, partFaceProxy)
				End If
				
	   			drawViewCurves = drawView.DrawingCurves(partFaceProxy)
	   			Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
				Return drawViewCurves(1)
			Catch
	    		Logger.Info("Error curve count")
			End Try

		End If
	Next
	
End Function

I don't know your exact intentions with this code, but I'd suggest filtering out the curves based on type, direction etc. depending on your intentions.
Here's an example filtering out the horizontal lines and setting the dimension between them:

Sub Main
	
	Dim curve As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing segment").Parent					
	modelGeom = curve.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence
	Dim drawView As DrawingView = curve.Parent
	Dim drawSheet As Sheet = drawView.Parent

	MessageBox.Show(occ.Name, "Title")
	Dim curve1 As DrawingCurve = Nothing
	Dim curve2 As DrawingCurve = Nothing
	
	Dim horizontalLines As List(Of DrawingCurve) = GetHorizontalLines("Face0", occ, drawView)

	curve1 = horizontalLines(0)
	curve2 = horizontalLines(1)

	
	Dim tg As TransientGeometry = ThisApplication.TransientGeometry

	Dim pt1 As Point2d = tg.CreatePoint2d(curve1.StartPoint.X + 2, curve1.StartPoint.Y)

	Dim genDims As GeneralDimensions = drawSheet.DrawingDimensions.GeneralDimensions

	Dim dim1 As LinearGeneralDimension = genDims.AddLinear(pt1, drawSheet.CreateGeometryIntent(curve1), drawSheet.CreateGeometryIntent(curve2))
	dim1.CenterText
	
End Sub

Function  GetHorizontalLines(faceName As String, occ As ComponentOccurrence, drawView As DrawingView) As List(Of DrawingCurve)
	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities

	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity(faceName)
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces
		
		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
				If occ.HasBodyOverride
					For Each oSurfBod As SurfaceBody In occ.SurfaceBodies
						For Each oFace As Face In oSurfBod.Faces
							If oFace.GetSourceFace Is namedFace Then partFaceProxy = oFace
							Exit For
						Next
						If partFaceProxy IsNot Nothing Then Exit For
					Next
				Else
					occ.CreateGeometryProxy(namedFace, partFaceProxy)
				End If
				
	   			drawViewCurves = drawView.DrawingCurves(partFaceProxy)
				Return drawViewCurves.OfType(Of DrawingCurve).Where(Function(x As DrawingCurve) x.CurveType = CurveTypeEnum.kLineSegmentCurve AndAlso x.StartPoint.Y = x.EndPoint.Y).ToList()
			Catch
	    		Logger.Info("Error curve count")
			End Try

		End If
	Next
	
End Function

 

0 Likes
Message 13 of 13

A.Acheson
Mentor
Mentor
Accepted solution

Hi Mike, Thanks for checking the code and providing some debugging help. Actually it looks like Michael and Jhoel had the right idea earlier and I must have implemented it incorrectly. This rearrangement of Jhoel loop was all that was stopping the loop from working. Thanks to everyone involved. Lots of different approaches used hopefully I can get it to work in the project files. 

 

Working sample for a regular part. 

For Each oFace As Face In oSurfBod.Faces
    If oFace.GetSourceFace Is namedFace Then 
       partFaceProxy = oFace
     Exit For
   End If
Next

 

As for the end goal I am actually dealing with retrieving sloped faces in order to auto dimensions with an iPart as the source and everything was working until the hole was introduced at the assembly level.

Sub Main
	
	Dim curve As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a drawing segment").Parent					
	modelGeom = curve.ModelGeometry
	Dim occ As ComponentOccurrence = modelGeom.ContainingOccurrence
	Dim drawView As DrawingView = curve.Parent
	Dim drawSheet As Sheet = drawView.Parent

	MessageBox.Show(occ.Name, "Title")
	
	Dim curve1 As DrawingCurve = Nothing
	Dim curve2 As DrawingCurve = Nothing

	curve1 = GetCurve("Face0", occ, drawView)
	
	curve2 = GetCurve("Face1", occ, drawView)
	
	Dim tg As TransientGeometry = ThisApplication.TransientGeometry

	Dim pt1 As Point2d = tg.CreatePoint2d(curve1.StartPoint.X + 2, curve1.StartPoint.Y)

	Dim genDims As GeneralDimensions = drawSheet.DrawingDimensions.GeneralDimensions

	Dim dim1 As LinearGeneralDimension = genDims.AddLinear(pt1, drawSheet.CreateGeometryIntent(curve1), drawSheet.CreateGeometryIntent(curve2))
	dim1.CenterText
	
End Sub

Function  GetCurve(faceName As String, occ As ComponentOccurrence, drawView As DrawingView) As DrawingCurve
	
	Dim doc As PartDocument = occ.Definition.Document
	Dim drawViewCurves As DrawingCurvesEnumerator
	Dim partFaceProxy As FaceProxy
	Dim namedEntities As NamedEntities
	Dim namedface As Object
	
	namedEntities = iLogicVb.Automation.GetNamedEntities(doc)

	Try
		namedFace = namedEntities.FindEntity(faceName)
	Catch
		Logger.Info("Error getting face entity")
	End Try

	For Each partFace As Face In doc.ComponentDefinition.SurfaceBodies(1).Faces
		
		If partFace Is namedFace Then
			MessageBox.Show("Found Face", "Title")
			Try
				If occ.HasBodyOverride
					For Each oSurfBod As SurfaceBody In occ.SurfaceBodies
						For Each oFace As Face In oSurfBod.Faces
							If oFace.GetSourceFace Is namedFace Then 
								partFaceProxy = oFace
								Exit For
							End If
						Next
						If partFaceProxy IsNot Nothing Then Exit For
					Next
				Else
					occ.CreateGeometryProxy(namedFace, partFaceProxy)
				End If
				
	   			drawViewCurves = drawView.DrawingCurves(partFaceProxy)
	   			Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
				Return drawViewCurves(1)
			Catch
	    		Logger.Info("Error curve count")
			End Try

		End If
	Next
	
End Function

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes