Having trouble with WorkPoints.AddByCurveAndEntity

Having trouble with WorkPoints.AddByCurveAndEntity

gs104
Explorer Explorer
112 Views
1 Reply
Message 1 of 2

Having trouble with WorkPoints.AddByCurveAndEntity

gs104
Explorer
Explorer

I'm trying to make a rule that creates a workpoint at the intersection of a the YZ plane and an edge using ilogic. The edge will be in the named entity (called Edge0 right now) tab in under ilogic. I will worry about [ProximityPoint] later. I don't think this is too hard, but I am a beginner with ilogic and I couldn't find something on here that explained it in a way I could understand. Here's what I wrote

 

Dim partDoc As PartDocument = ThisDoc.ModelDocument
oDef = ThisDoc.Document.ComponentDefinition
Dim namedEntities = iLogicVb.Automation.GetNamedEntities(partDoc)
Dim Edge0 As Edge = namedEntities.FindEntity("Edge0")
Dim YZ As WorkPlane = oDef.WorkPlanes("YZ Plane")
Dim oWPoint As WorkPoint oWPoint = WorkPoints.AddByCurveAndEntity(Edge0, YZ)

 The error I am getting is Error on Line 17 : Reference to a non-shared member requires an object reference. I've tried making both the curve and the edge different types of objects. What am I doing wrong?

I'm sure its easy. Unfortunately, I'm just getting started with ilogic and programming in general.

 

Thanks in advance.

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

Michael.Navara
Advisor
Advisor

Hi @gs104

The issue is on line 7, where you need to access WorkPoints property of the PartComponentDefinition.

 

Dim partDoc As PartDocument = ThisDoc.ModelDocument
Dim oDef As PartComponentDefinition = partDoc.ComponentDefinition
Dim namedEntities As NamedEntities = iLogicVb.Automation.GetNamedEntities(partDoc)
Dim Edge0 As Edge = namedEntities.FindEntity("Edge0")
Dim YZ As WorkPlane = oDef.WorkPlanes("YZ Plane")
Dim oWPoint As WorkPoint
oWPoint = oDef.WorkPoints.AddByCurveAndEntity(Edge0, YZ) 

 

Notes:

  • I recommend you to explicitly specify a type of variables. It helps you to use IntelliSense during code editing. 
  • Use entry point such a ThisDoc (ThisApplication, ThisDrawing, etc.) minimal times as possible.
0 Likes