Trying to generate workpoints using named geometry

Trying to generate workpoints using named geometry

jessey9X6M8
Enthusiast Enthusiast
4,466 Views
34 Replies
Message 1 of 35

Trying to generate workpoints using named geometry

jessey9X6M8
Enthusiast
Enthusiast

I am trying to use iLogic to generate an array of workpoints on the hull of a tugboat (to export heights to an Excel sheet indexed by x,y coordinates), but I keep getting the following error message:

Error in rule: Generate_WPoints, in document: Hull Shape.ipt

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Face'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5DF8608B-6B16-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

and under "More Info":

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Face'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5DF8608B-6B16-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
   at ThisRule.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

I think it has something to do with the named geometry I am trying to use.  I have a surface model of the hull, which includes 15 surfaces that I have named Hull0 - Hull14.  I have written one rule to generate a grid of vertical workplanes and another to generate work axes at the intersections of the workplanes, each guided by parameters for overall width and length, along with the desired mesh size.  That brings us to the code in question.  

 

	'Set up variables for the current part document and its components.
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
	'This line is necessary to work with named geometry.
Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
	'These variables are to intersect axes with surfaces to generate points.
Dim oPoint As WorkPoint
Dim oAxis As WorkAxis
Dim oHull As Face
	'Define and initialize incrementing variables starting at FWD Port corner.
Dim X, Y As Integer
X = 0
Y = -1 * Mesh * Floor(OAW / Mesh / 2) / (1 in)
	'Increment through all existing work axes.  Find which, if any, hull surface
	'each axis intersects with, create a workpoint there, and name it.
While Y <= OAW / (2 in)
	X = 0
	While X <= OAL / (1 in)
		oAxis = oDef.WorkAxes.Item("Axis_" & CStr(X) & "_" & CStr(Y))
		For k = 0 To 14
			oHull = oNames.FindEntity("Hull" & CStr(k))
			oPoint = oDef.WorkPoints.AddByCurveAndEntity(oHull, oAxis)
			oPoint.Name = "Point_" & CStr(X) & "_" & CStr(Y)
		Next
		X = X + Mesh / (1 in)
	End While
	Y = Y + Mesh / (1 in)
End While

 I would greatly appreciate the silver bullet for the error in this code.  However, I would just as heartily welcome any constructive suggestions improving my workflow.

0 Likes
Accepted solutions (1)
4,467 Views
34 Replies
Replies (34)
Message 21 of 35

JhoelForshav
Mentor
Mentor

Hi @jessey9X6M8 

I see now that the faces you want to use is in a NonParametricBaseFeature. Appearantly such faces are difficult to reach/use in code. I think I understand what you want now though 🙂

 

I wrote this rule to patch and stitch the hull and then use the surfacebody from the stitch to create a point grid on the XY-plane. Then i take this pointgrid and by FindUsingRay i create the projected points on the hull.

 

Try
 Dim oDoc As PartDocument = ThisDoc.Document
 Dim oFeatures = oDoc.ComponentDefinition.Features
 Dim oFaces As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
 Dim tg As TransientGeometry = ThisApplication.TransientGeometry
 Dim oPoint As Point = tg.CreatePoint(0, 0, 0)
 Dim oList As New List(Of String)

 For Each oFace As Face In oFeatures.NonParametricBaseFeatures(1).Faces
  Dim fP As Point = oFace.GetClosestPointTo(oPoint)
  Dim fpString As String = Round(fP.X, 1).ToString & Round(fP.Y, 1).ToString & Round(fP.Z, 1).ToString
  Dim oBPdef As BoundaryPatchDefinition = oFeatures.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
  If oList.Contains(fpString) = False
   oBPdef.BoundaryPatchLoops.Add(oFace.EdgeLoops(1))
   oFaces.Add(oFeatures.BoundaryPatchFeatures.Add(oBPdef).SurfaceBodies(1))
   oList.Add(fpString)
  End If
 Next

 Dim oHull As KnitFeature = oFeatures.KnitFeatures.Add(oFaces, , True)

 Dim body As SurfaceBody = oHull.SurfaceBodies(1)

 ThisApplication.UserInterfaceManager.DoEvents


 Dim oPointsX As Integer = 20
 Dim oPointsY As Integer = 20


 Dim vertCount As Integer
 Dim facetCount As Integer
 Dim vertCoords() As Double = {}
 Dim normVectors() As Double = {}
 Dim vertInds() As Integer = {}

 Dim tolCount As Long
 Dim tols() As Double = {}
 Call body.GetExistingFacetTolerances(tolCount, tols)
 Dim bestTol As Double
 bestTol = tols(0)



 For i As Integer = 1 To tolCount - 1
  If tols(i) < bestTol Then
   bestTol = tols(i)
  End If
 Next



 body.GetExistingFacets(bestTol, vertCount, facetCount, vertCoords, normVectors, vertInds)

 Dim smallPnt As Point = tg.CreatePoint(vertCoords(0), vertCoords(1), 0)
 Dim largePnt As Point = tg.CreatePoint(vertCoords(0), vertCoords(1), 0)


 For i As Integer = 1 To vertCount - 1
  Dim vertX As Double = vertCoords(i * 3)
  Dim vertY As Double = vertCoords(i * 3 + 1)

  If vertX < smallPnt.X Then
   smallPnt.X = vertX
  End If

  If vertY < smallPnt.Y Then
   smallPnt.Y = vertY
  End If

  If vertX > largePnt.X Then
   largePnt.X = vertX
  End If

  If vertY > largePnt.Y Then
   largePnt.Y = vertY
  End If
 Next


 Dim ox As Double = (largePnt.X - smallPnt.X) / oPointsX
 Dim oy As Double = (largePnt.Y - smallPnt.Y) / oPointsY
 Dim oPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
 For i = 0 To oPointsX
  For j = 0 To oPointsY
   oPoints.Add(tg.CreatePoint(smallPnt.X + (i * ox), smallPnt.Y + (j * oy), 0))
  Next
 Next

 Dim oZvector As UnitVector = tg.CreateUnitVector(0, 0, 1)
 Dim foundEnts As ObjectsEnumerator
 Dim locPoints As ObjectsEnumerator
 For Each pnt As Point In oPoints
  Call body.FindUsingRay(pnt, oZvector, 0.00001, foundEnts, locPoints, True)
  If locPoints.Count > 0 Then
   oDoc.ComponentDefinition.WorkPoints.AddFixed(locPoints.Item(1))
  End If

 Next
Catch
 'Something went wrong
End Try

Since there are some duplicate faces etc in the NonParametricBaseFeature I had tofind a way to not include all of them in order to get the stitch (knit) to work, but I think i found an acceptable way to do this.

 

 
 
 
 
 
 
 
 
 
 
Message 22 of 35

JhoelForshav
Mentor
Mentor

The number of points created are controled by oPointsX and oPointsY in the code.

For example if you change it to make the grid we project to the surface 60x40 points you'll get a much tighter grid:

 Dim oPointsX As Integer = 60
 Dim oPointsY As Integer = 40

6040.PNG

Message 23 of 35

Anonymous
Not applicable

I'm guessing the Named Entities includes all of your planes and axes as well. If Hull0-14 are the first 15 entities then this might work. I'm using k+1 because it seems the index starts at 1 rather than 0

For k = 0 To 14
			oHull = oNames.Entities.Item(k+1)
			oPoint = oDef.WorkPoints.AddByCurveAndEntity(oHull, oAxis)
			oPoint.Name = "Point_" & CStr(X) & "_" & CStr(Y)
		Next

 

If not or you want a safer option, try a for loop 

 

Dim oHull as List(Of Object) = New List(Of Object)
' OR
'Dim oHull as List(Of Face) = New List(Of Face)

For i = 1 to oNames.Entities.Count
Dim oObj as Object = oNames.Entities.Item(i)
If oObj.Name.Contains("Hull") Then
oHull.Add(oObj)
End if
Next

'~~~~~~~~~~

For k = 0 To 14
			
	oPoint = oDef.WorkPoints.AddByCurveAndEntity(oHull(k), oAxis)
	oPoint.Name = "Point_" & CStr(X) & "_" & CStr(Y)
Next

 

I'm not sure which List will work, so I'd try both. Hopefully the .Name function will work on a Object since it should be returning Inventor features

0 Likes
Message 24 of 35

jessey9X6M8
Enthusiast
Enthusiast

All sorts of interesting new errors to try to understand.  {(-:]

Trying to integrate your first solution yielded this:

Error in rule: Test, in document: Hull Shape.ipt

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Face'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5DF8608B-6B16-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

The second one gave this:

Error in rule: Test, in document: Hull Shape.ipt

Public member 'Name' on type 'Edge' not found.
0 Likes
Message 25 of 35

Anonymous
Not applicable

On the first one you would have to define oHull as an Object instead of a Face again. Sorry I should have included that in my code. 

 

Second, I was afraid of that. I don't know what all is included in the NamedEntities, but I hoped they all had a .Name function. Adding a filter for Face type should solve it.

 

Dim oHull as List(Of Face) = New List(Of Face)

For i = 1 to oNames.Entities.Count
Dim oObj as Object = oNames.Entities.Item(i)
If TypeOf oObj is Face Then
If oObj.Name.Contains("Hull") Then
oHull.Add(oObj)
End If
End If
Next

'~~~~~~~~~~

For k = 0 To 14
			
	oPoint = oDef.WorkPoints.AddByCurveAndEntity(oHull(k), oAxis)
	oPoint.Name = "Point_" & CStr(X) & "_" & CStr(Y)
Next

 

 

0 Likes
Message 26 of 35

Anonymous
Not applicable

My second solution won't work unfortunately. I was under the impression Face type had .Name, but I was mistaken.

It may still work if the only faces in NamedEntites are your Hull0-14, but you remove the name check.

 

For i = 1 to oNames.Entities.Count
Dim oObj as Object = oNames.Entities.Item(i)
If TypeOf oObj is Face Then
oHull.Add(oObj)
End If
Next
0 Likes
Message 27 of 35

jessey9X6M8
Enthusiast
Enthusiast

We are so close, I can taste it.

 

Error in rule: Test, in document: Hull Shape.ipt

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

More Info:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.WorkPoints.AddByCurveAndEntity(Object Curve, Object Entity, Object ProximityPoint, Boolean Construction)
   at ThisRule.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Incidentally, iLLogic tastes like chalk.

0 Likes
Message 28 of 35

Anonymous
Not applicable

Ok so, I downloaded your model to attempt to test this without so much back and forth. I'm not sure if I'll get it by the end of the day. Side note I noticed your Hull0 is actually a named Line and not a face. I changed it to the face I assumed it was meant to be, but still getting an error.

 

 

 

 

0 Likes
Message 29 of 35

Anonymous
Not applicable

It takes a little bit to run, but if you only need to run it once it shouldn't be a big deal.

 

Almost there, I'm about to leave for the day, but I got it to create a work point and name it (Named WPoint_0_-196), create a second point, but errors when naming it. So I'm not sure how you want your naming system to work, but how it is now causes an error, because I think it's trying to name the second point the same as the first.

 

 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oAxis As WorkAxis
Dim oHull As List(Of Face) = New List(Of Face)

For i = 1 To oNames.Entities.Count
Dim oObj As Object = oNames.Entities.Item(i)

	If TypeOf oObj Is Face Then
		oHull.Add(oObj)
	End If
Next

Dim X, Y As Integer
X = 0
Y = -1 * Mesh * Floor(OAW / Mesh / 2) / (1 in)

While Y <= OAW / (2 in)
	X = 0
	While X <= OAL / (1 in)
		oAxis = oDef.WorkAxes.Item("Axis_" & CStr(X) & "_" & CStr(Y))
		For k = 0 To 14
			
			Dim oWPoint As WorkPoint
			oWPoint = oDef.WorkPoints.AddByCurveAndEntity(oAxis, oHull(k))
			oWPoint.Name = "WPoint_" & CStr(X) & "_" & CStr(Y)
			
		Next
		X = X + Mesh / (1 in)
	End While
	Y = Y + Mesh / (1 in)
End While

 

0 Likes
Message 30 of 35

jessey9X6M8
Enthusiast
Enthusiast

Thank you for that.  I had not thought to make a list of faces before you mentioned it.

 

But there should only be at most one point generated at each x,y pair.  And many locations should not have a point because there is no intersection.  The fact that it generated a point at (0,-196) is interesting, since there is no hull there. 

 

I have tried to address this behavior by inserting an "if" statement in the "for" loop to only generate a point if there is an intersection.  I thought to use

Measure.MinimumDistance(oAxis, oHull(k)) = 0

 as the criterion, but that function returns an error:

Error in rule: Test, in document: Hull Shape.ipt

Measure.MinimumDistance: No entity named "System.__ComObject" was found.

 

But this is getting very close to the desired outcome.  Thanks again for your efforts thus far.

0 Likes
Message 31 of 35

Anonymous
Not applicable

So after some testing, I don't think getting the faces from NamedEntities works the way we're trying to use it,but all is not lost. I borrowed Jhoelforshav's method of creating a surface body from the faces and used that instead. This is the result.

 

Annotation 2020-06-19 103214.png

There are a couple issues. There are several stragglers that aren't an intersection that I have no explanation for. Also it seems Jhoelforshav's method left out those 2 middle faces without workpoints. It also seemed to include the XY plane because the first couple tests there was a flat plane of workpoints underneath the hull. I was able exclude it manually as you will see in the code. I'm not sure how much further I can go with this because I don't really know how Jhoelforshav's method works, why it left out those 2 faces and included the XY plane, or why it created some points that aren't an intersection. I will post the code, but beware it took almost 10 minutes to run. This code is going through every axes and checking if intersects each face. I included a check so if it created a point for an axis it will stop trying to create points for that axis. It also skips the XY plane in the if statement (Not k = 3).

 

Honestly, I would recommend using Jhoelforshav's solution as it seems way more elegant and flexible

 

 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oAxis As WorkAxis

Dim oFeatures = oDoc.ComponentDefinition.Features
Dim oFaces As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim tg As TransientGeometry = ThisApplication.TransientGeometry
Dim oPoint As Point = tg.CreatePoint(0, 0, 0)
Dim oList As New List(Of String)

For Each oFace As Face In oFeatures.NonParametricBaseFeatures(1).Faces
  Dim fP As Point = oFace.GetClosestPointTo(oPoint)
  Dim fpString As String = Round(fP.X, 1).ToString & Round(fP.Y, 1).ToString & Round(fP.Z, 1).ToString
  Dim oBPdef As BoundaryPatchDefinition = oFeatures.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
  If oList.Contains(fpString) = False
   oBPdef.BoundaryPatchLoops.Add(oFace.EdgeLoops(1))
   oFaces.Add(oFeatures.BoundaryPatchFeatures.Add(oBPdef).SurfaceBodies(1))
   oList.Add(fpString)
  End If
Next

 Dim oHull As KnitFeature = oFeatures.KnitFeatures.Add(oFaces, , True)

 Dim body As SurfaceBody = oHull.SurfaceBodies(1)
 
Dim X, Y As Integer
X = 0
Y = -1 * Mesh * Floor(OAW / Mesh / 2) / (1 in)

Dim Found As Boolean

While Y <= OAW / (2 in)
	X = 0
	While X <= OAL / (1 in) 
		oAxis = oDef.WorkAxes.Item("Axis_" & CStr(X) & "_" & CStr(Y))
		
		For k = 1 To body.Faces.Count
			If Not Found And Not k = 3 Then
				Try
					Dim oWPoint As WorkPoint
					oWPoint = oDef.WorkPoints.AddByCurveAndEntity(oAxis, body.Faces(k))
					oWPoint.Name = "WPoint_" & CStr(X) & "_" & CStr(Y)
					Found = True
				
				Catch
				End Try
			Else
			End If
		
		Next
		
		Found = False
		X = X + Mesh / (1 in)
		
	End While
	
	Y = Y + Mesh / (1 in)
	
End While

 

 

 

0 Likes
Message 32 of 35

jessey9X6M8
Enthusiast
Enthusiast

Thank you for this piece of code.  I have run it, and it does mostly what I need, with the aberrations you mentioned.  I am currently perusing it at length to make sure I understand what is going on, but I did want to touch base before time gets away from me. 

0 Likes
Message 33 of 35

Anonymous
Not applicable

After stitching together some more of Jhoelforshav's code, I nearly have it. the only thing missing is the naming.

 

Annotation 2020-06-19 144549.png

 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oAxis As WorkAxis

Dim oFeatures = oDoc.ComponentDefinition.Features
Dim oFaces As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim tg As TransientGeometry = ThisApplication.TransientGeometry
Dim oPoint As Point = tg.CreatePoint(0, 0, 0)
Dim oList As New List(Of String)

For Each oFace As Face In oFeatures.NonParametricBaseFeatures(1).Faces
  Dim fP As Point = oFace.GetClosestPointTo(oPoint)
  Dim fpString As String = Round(fP.X, 1).ToString & Round(fP.Y, 1).ToString & Round(fP.Z, 1).ToString
  Dim oBPdef As BoundaryPatchDefinition = oFeatures.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
  If oList.Contains(fpString) = False
   oBPdef.BoundaryPatchLoops.Add(oFace.EdgeLoops(1))
   oFaces.Add(oFeatures.BoundaryPatchFeatures.Add(oBPdef).SurfaceBodies(1))
   oList.Add(fpString)
  End If
Next

 Dim oHull As KnitFeature = oFeatures.KnitFeatures.Add(oFaces, , True)
 
 Dim body As SurfaceBody = oHull.SurfaceBodies(1)
 
Dim X, Y As Integer
X = 0
Y = -1 * Mesh * Floor(OAW / Mesh / 2) / (1 in)

Dim Found As Boolean
Dim oPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim XYPlane As WorkPlane = oDef.WorkPlanes.Item(3)

While Y <= OAW / (2 in)
	X = 0
	While X <= OAL / (1 in)
		
		oAxis = oDef.WorkAxes.Item("Axis_" & CStr(X) & "_" & CStr(Y))
		
		Dim oLine As Line = oAxis.Line
		Dim oWPoints As ObjectsEnumerator = oLine.IntersectWithSurface(XYPlane.Plane)
		Dim oWpoint As Point = oWPoints(1)
		
			If Not oWpoint Is Nothing Then
				oPoints.Add(oWpoint)
			End If

		X = X + Mesh / (1 in)
		
	End While
	
	Y = Y + Mesh / (1 in)
	
End While

For Each oPoint2 As Point In oPoints
	
	Dim oZvector As UnitVector = tg.CreateUnitVector(0, 0, 1)
	Dim foundEnts As ObjectsEnumerator
	Dim locPoints As ObjectsEnumerator

	body.FindUsingRay(oPoint2, oZvector, 0.00001, foundEnts, locPoints, True)
	If locPoints.Count > 0 Then
	oDoc.ComponentDefinition.WorkPoints.AddFixed(locPoints.Item(1))

	End If
	
Next
	
0 Likes
Message 34 of 35

Anonymous
Not applicable
Accepted solution

Naming them was a lot easier than expected. This code should do exactly what you are looking for and it's fast.

 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oAxis As WorkAxis
Dim oPoints As Dictionary(Of String,Point) = New Dictionary(Of String,Point)

Dim oFeatures = oDoc.ComponentDefinition.Features
Dim oFaces As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim tg As TransientGeometry = ThisApplication.TransientGeometry
Dim oPoint As Point = tg.CreatePoint(0, 0, 0)
Dim oList As New List(Of String)

For Each oFace As Face In oFeatures.NonParametricBaseFeatures(1).Faces
  Dim fP As Point = oFace.GetClosestPointTo(oPoint)
  Dim fpString As String = Round(fP.X, 1).ToString & Round(fP.Y, 1).ToString & Round(fP.Z, 1).ToString
  Dim oBPdef As BoundaryPatchDefinition = oFeatures.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
  If oList.Contains(fpString) = False
   oBPdef.BoundaryPatchLoops.Add(oFace.EdgeLoops(1))
   oFaces.Add(oFeatures.BoundaryPatchFeatures.Add(oBPdef).SurfaceBodies(1))
   oList.Add(fpString)
  End If
Next

 Dim oHull As KnitFeature = oFeatures.KnitFeatures.Add(oFaces, , True)
 
 Dim body As SurfaceBody = oHull.SurfaceBodies(1)
 
Dim X, Y As Integer
X = 0
Y = -1 * Mesh * Floor(OAW / Mesh / 2) / (1 in)

Dim Found As Boolean
'Dim oPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim XYPlane As WorkPlane = oDef.WorkPlanes.Item(3)

While Y <= OAW / (2 in)
	X = 0
	While X <= OAL / (1 in)
		
		oAxis = oDef.WorkAxes.Item("Axis_" & CStr(X) & "_" & CStr(Y))
		
		Dim oLine As Line = oAxis.Line
		Dim oWPoints As ObjectsEnumerator = oLine.IntersectWithSurface(XYPlane.Plane)
		Dim oWpoint As Point = oWPoints(1)
		
			If Not oWpoint Is Nothing Then
				oPoints.Add(X & "." & Y,oWpoint)
			End If

		X = X + Mesh / (1 in)
		
	End While
	
	Y = Y + Mesh / (1 in)
	
End While

For Each oKVP As KeyValuePair(Of String, Point)In oPoints
	
	Dim oZvector As UnitVector = tg.CreateUnitVector(0, 0, 1)
	Dim foundEnts As ObjectsEnumerator
	Dim locPoints As ObjectsEnumerator

	body.FindUsingRay(oKVP.Value, oZvector, 0.00001, foundEnts, locPoints, True)
	
	If locPoints.Count > 0 Then
	
		Dim oNewPoint As WorkPoint = oDoc.ComponentDefinition.WorkPoints.AddFixed(locPoints.Item(1))
		
		Dim oName() As String = oKVP.Key.Split(".")
		Dim XName As String = oName(0)
		Dim YName As String = oName(1)
		
		oNewPoint.Name = "WPoint_" & XName & "_" & YName
	
	End If
	
Next
Message 35 of 35

jessey9X6M8
Enthusiast
Enthusiast

Awesome!

 

As advertised, it does all I need it to, and it works fast.  Thank you for your herculean efforts.

 

Also, thank you to @JhoelForshav for having the key insights that I was not ready for several days ago.

0 Likes