Create workpoint from 3 planes

Create workpoint from 3 planes

keithjk
Advocate Advocate
1,631 Views
11 Replies
Message 1 of 12

Create workpoint from 3 planes

keithjk
Advocate
Advocate

I am trying to create a work point from 3 work planes that are created in the same sub routine.  The 3 work planes are create properly but I get an error when I try to create the work planes. 

 

The following is a snippet from the code.  Everything works properly up to "wpNew = oAsmCompDef1.WorkPoints.AddByThreePlanes(oNewWorkPlane1, oNewWorkPlane2, oNewWorkPlane3)"

 

Also attached is the error message. 

 

Any ideas?

 

..

'set up the work plane proxys

Dim oWorkPlaneProxy1 As WorkPlaneProxy = Nothing

oEnclosure.CreateGeometryProxy(oAssyPlane1, oWorkPlaneProxy1)

Dim oWorkPlaneProxy2 As WorkPlaneProxy = Nothing

oEnclosure.CreateGeometryProxy(oAssyPlane2, oWorkPlaneProxy2)

Dim oWorkPlaneProxy3 As WorkPlaneProxy = Nothing

oEnclosure.CreateGeometryProxy(oAssyPlane3, oWorkPlaneProxy3)

'these are the new assembly work planes

Dim oNewWorkPlane1 As WorkPlane = Nothing

Dim oNewWorkPlane2 As WorkPlane = Nothing

Dim oNewWorkPlane3 As WorkPlane = Nothing

Call oWorkPlaneProxy1.GetPosition(oOriginPnt, oXaxis, oYaxis)

oNewWorkPlane1 = oAsmCompDef1.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis)

oNewWorkPlane1.Name = oNewWorkPlaneName1

Call oWorkPlaneProxy2.GetPosition(oOriginPnt, oXaxis, oYaxis)

oNewWorkPlane2 = oAsmCompDef1.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis)

oNewWorkPlane2.Name = oNewWorkPlaneName2

Call oWorkPlaneProxy3.GetPosition(oOriginPnt, oXaxis, oYaxis)

oNewWorkPlane3 = oAsmCompDef1.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis)

oNewWorkPlane3.Name = oNewWorkPlaneName3

Dim wpNew As WorkPoint

wpNew = oAsmCompDef1.WorkPoints.AddByThreePlanes(oNewWorkPlane1, oNewWorkPlane2, oNewWorkPlane3)

 

0 Likes
Accepted solutions (2)
1,632 Views
11 Replies
Replies (11)
Message 2 of 12

HermJan.Otterman
Advisor
Advisor
Accepted solution

I tried to do it aswell, didn't work.

 

looked in the help, there it says:  This method is not currently supported when creating a workpoint within an assembly

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 12

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi Keith,

 

In an Assembly, Workpoints can be created only using WorkpoInts.AddFixed method. Other methods are not supported. But using UI, WorkPoints can be created using "Intersection of Three Planes" as shown in the below image.

 

WorkPoint.png

 

In a Part, Workpoints can be created easily using WorkPoints.AddByThreePlanes.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 12

keithjk
Advocate
Advocate

Herm Jan,

 

Thanks for the answer.

 

My work points do need to be placed at the intersection of three work planes.  Since addfixed seems to be the only way of adding them, do you have any  suggestions on how to get the intersection of the three work planes?

 

Keith

0 Likes
Message 5 of 12

keithjk
Advocate
Advocate
Accepted solution

I figured it out....

 

I get the origin points of the 3 work planes and then determine the intersection of them by getting their x,y,z origin points.  I then use the workpoints.addfixed method.

 

Thanks for the help.  You got me pointed in the right direction.

0 Likes
Message 6 of 12

GeorgK
Advisor
Advisor

Hello keithjk,

 

is it possible that you post your code?

 

Thank you

 

Georg

0 Likes
Message 7 of 12

keithjk
Advocate
Advocate

Georg,

 

I got pulled away from this project but I did write some rough code to see if I could make it work. (So I know I should be able to clean it up when I get back to it).  The snippet below should give you an idea on how it works.

 

...

Dim oXaxis As UnitVector = Nothing

Dim oYaxis As UnitVector = Nothing

 

'these are the existing work planes

Dim oAssyPlane1 As WorkPlane = oOccDef1.WorkPlanes.Item("WP_Door")

Dim oAssyPlane2 As WorkPlane = oOccDef1.WorkPlanes.Item("WP_Left Side")

Dim oAssyPlane3 As WorkPlane = oOccDef1.WorkPlanes.Item("WP_Top")

 

'set up the work plane proxys

Dim oWorkPlaneProxy1 As WorkPlaneProxy = Nothing

oEnclosure.CreateGeometryProxy(oAssyPlane1, oWorkPlaneProxy1)

Dim oWorkPlaneProxy2 As WorkPlaneProxy = Nothing

oEnclosure.CreateGeometryProxy(oAssyPlane2, oWorkPlaneProxy2)

Dim oWorkPlaneProxy3 As WorkPlaneProxy = Nothing

oEnclosure.CreateGeometryProxy(oAssyPlane3, oWorkPlaneProxy3)

 

'evaluate the 3 work planes

Dim oOriginPnt1 As Inventor.Point = Nothing

Call oWorkPlaneProxy1.GetPosition(oOriginPnt1, oXaxis, oYaxis)

Dim pt1 As Double = oOriginPnt1.Z

 

Dim oOriginPnt2 As Inventor.Point = Nothing

Call oWorkPlaneProxy2.GetPosition(oOriginPnt2, oXaxis, oYaxis)

Dim pt2 As Double = oOriginPnt2.X

 

Dim oOriginPnt3 As Inventor.Point = Nothing

Call oWorkPlaneProxy3.GetPosition(oOriginPnt3, oXaxis, oYaxis)

Dim pt3 As Double = oOriginPnt3.Y

 

Dim newPoint As Inventor.Point = oTG.CreatePoint(pt2, pt3, pt1)

Dim wpNew As WorkPoint = oAsmCompDef1.WorkPoints.AddFixed(newPoint)

Message 8 of 12

GeorgK
Advisor
Advisor

Hello keithjk,

 

thank you very much

 

Georg

0 Likes
Message 9 of 12

gkniksch
Participant
Participant

This thread was helpful. I didn't realize that "AddFixed" was the only method supported in Assemblies. Knowing that, I used that method to add a point arbitrarily in space, followed by constraining the new point to the three planes I was originally looking to use to add the point with. The three planes included two origin planes in the assembly and one workplane within another component. The component workplane required a workplaneproxy to access it.

 

I thought sharing this might be helpful to someone in the future. Cheers.

 

Set oWpt = oAssyDoc.ComponentDefinition.WorkPoints.AddFixed(oTg.CreatePoint(1, 1, 1))
oWpt.Grounded = False
Call oAssyDoc.ComponentDefinition.Constraints.AddMateConstraint(oWpt, oAssyYZ, "0")
Call oAssyDoc.ComponentDefinition.Constraints.AddMateConstraint(oWpt, oAssyXY, "0")
Call oAssyDoc.ComponentDefinition.Constraints.AddMateConstraint(oWpt, oPlaneFloorLengthProxy, "0")
0 Likes
Message 10 of 12

GeorgK
Advisor
Advisor

Thank you all for your help.

Georg

0 Likes
Message 11 of 12

llorden4
Collaborator
Collaborator

This appears to be a feature I've been long working on and needing.  I'm having a bit of trouble on the declarations, perhaps someone can assist...

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmCompDef As ComponentDefinition = oDoc.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

Dim oXaxis As UnitVector = Nothing
Dim oYaxis As UnitVector = Nothing
Dim oEnclosure As ComponentOccurrence     'I think this declaration is my issue but can't pinpoint which to use

'these are the existing work planes
Dim oAssyPlane1 As WorkPlane = oAsmCompDef.WorkPlanes.Item("Plane1")
Dim oAssyPlane2 As WorkPlane = oAsmCompDef.WorkPlanes.Item("Plane2")
Dim oAssyPlane3 As WorkPlane = oAsmCompDef.WorkPlanes.Item("Plane3")

'set up the work plane proxys
Dim oWorkPlaneProxy1 As WorkPlaneProxy = Nothing
oEnclosure.CreateGeometryProxy(oAssyPlane1, oWorkPlaneProxy1)
Dim oWorkPlaneProxy2 As WorkPlaneProxy = Nothing
oEnclosure.CreateGeometryProxy(oAssyPlane2, oWorkPlaneProxy2)
Dim oWorkPlaneProxy3 As WorkPlaneProxy = Nothing
oEnclosure.CreateGeometryProxy(oAssyPlane3, oWorkPlaneProxy3)

'evaluate the 3 work planes
Dim oOriginPnt1 As Inventor.Point = Nothing
Call oWorkPlaneProxy1.GetPosition(oOriginPnt1, oXaxis, oYaxis)
Dim pt1 As Double = oOriginPnt1.Z

Dim oOriginPnt2 As Inventor.Point = Nothing
Call oWorkPlaneProxy2.GetPosition(oOriginPnt2, oXaxis, oYaxis)
Dim pt2 As Double = oOriginPnt2.X

Dim oOriginPnt3 As Inventor.Point = Nothing
Call oWorkPlaneProxy3.GetPosition(oOriginPnt3, oXaxis, oYaxis)
Dim pt3 As Double = oOriginPnt3.Y

Dim newPoint As Inventor.Point = oTG.CreatePoint(pt2, pt3, pt1)
Dim wpNew As WorkPoint = oAsmCompDef.WorkPoints.AddFixed(newPoint)

I'm currently getting this error:  Object variable or With block variable not set.

 

I making some educated guesses at some of the declarations you used in your post, clearly I'm not getting one or more correct.  Would appreciate the correction.

Autodesk Inventor Certified Professional
0 Likes
Message 12 of 12

llorden4
Collaborator
Collaborator

A bit more digging on this solution, there are more issues than just the declarations to overcome.  The code was developed for planes that exist in a part file and in a specific manner, so without those files to compare the current code against then this is not going to deliver a solution.

 

My personal goal is to find the intersection of three planes created within an assembly file, so the Proxy call isn't necessary.  I'm also wanting to handle any plane orientation that creates a single point of intersection for all three planes; so the steps used to create a point here are not useful.

 

If I manage a solution, I'll post it in this thread where I've created a post looking for that solution or idea to share with others.

Autodesk Inventor Certified Professional
0 Likes