Inventor Customization

Inventor Customization

Reply
Valued Contributor
62 Posts
4 Kudos
Registered: ‎03-10-2011
Post 1 of 4
Accepted Solution

Create a workplane from a face in an assembly document

761 Views, 3 Replies
07-15-2011 11:00 AM

Hi,

 

In an assembly document, I try to add a MateConstraint between male and female side of an 45 degres elbow.

 

The male side is built on the XZ Plane and Y Axis And I try to create a workplane on the female face.

 

But a got an error with the last line of code.  Here's my code (vb.net code) :

 

' Get application object

Dim app As Inventor.Application = GetObject(, "Inventor.Application")           

Dim doc As Inventor.AssemblyDocument = app.ActiveDocument           

 

' Get the selected occurrence

Dim occ As Inventor.ComponentOccurrence = doc.SelectSet.Item(1)           

Dim body As Inventor.SurfaceBody = occ.SurfaceBodies(1)           

' Get the face on female side

Dim face As Inventor.Face = body.Faces(58)
Dim params(3), normals(3) As Double

face.Evaluator.GetNormal(params, normals)           

Dim vector As Inventor.Vector = app.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))           

Dim plane As Inventor.Plane = app.TransientGeometry.CreatePlane(face.PointOnFace, vector)           

 

Dim workplane As Inventor.WorkPlane = doc.ComponentDefinition.WorkPlanes.AddByPlaneAndPoint(plane, face.PointOnFace, True)

 

 

Thank for help.

 

Pascal

Thanks for your answer.

 

I've found a solution.  I didn't know that I could create constraint between FaceProxy and WorkPlaneProxy.

 

My solution:

 

Dim app As Inventor.Application = GetObject(, "Inventor.Application")
Dim doc As Inventor.AssemblyDocument = app.ActiveDocument
Dim occ As Inventor.ComponentOccurrence = doc.ComponentDefinition.Occurrences(1)
Dim occ2 As Inventor.ComponentOccurrence = doc.ComponentDefinition.Occurrences(2)
Dim faceProxy As Inventor.FaceProxy = occ.SurfaceBodies(1).Faces(58)
Dim wp As Inventor.WorkPlane = occ2.Definition.WorkPlanes.Item("XZ Plane")
Dim wpProxy As Inventor.WorkPlaneProxy = Nothing
occ2.CreateGeometryProxy(wp, wpProxy)
doc.ComponentDefinition.Constraints.AddFlushConstraint(wpProxy, faceProxy, "0""")

 

Pascal

Contributor
18 Posts
2 Kudos
Registered: ‎05-19-2011
Post 2 of 4

Re: Create a workplane from a face in an assembly document

07-18-2011 02:58 AM in reply to: planglais

Hi

 

Comments from the API Help Files for method AddByPlaneAndPoint :

 

"This method is not currently supported when creating a work plane within an assembly"

 

 

In an assembly document only AddFixed method is supported. This is valid for all kind of wokfeatures.

 

 

Philippe Leefsma
Developer Consultant
Developer Technical Services
Global Subscription & Support
 

Autodesk EMEA

  

www.autodesk.com/joinadn

Valued Contributor
62 Posts
4 Kudos
Registered: ‎03-10-2011
Post 3 of 4

Re: Create a workplane from a face in an assembly document

08-02-2011 05:14 AM in reply to: leefsma

Thanks for your answer.

 

I've found a solution.  I didn't know that I could create constraint between FaceProxy and WorkPlaneProxy.

 

My solution:

 

Dim app As Inventor.Application = GetObject(, "Inventor.Application")           
Dim doc As Inventor.AssemblyDocument = app.ActiveDocument           
Dim occ As Inventor.ComponentOccurrence = doc.ComponentDefinition.Occurrences(1)           
Dim occ2 As Inventor.ComponentOccurrence = doc.ComponentDefinition.Occurrences(2)

Dim faceProxy As Inventor.FaceProxy = occ.SurfaceBodies(1).Faces(58)
Dim wp As Inventor.WorkPlane = occ2.Definition.WorkPlanes.Item("XZ Plane")
Dim wpProxy As Inventor.WorkPlaneProxy = Nothing
occ2.CreateGeometryProxy(wp, wpProxy)

doc.ComponentDefinition.Constraints.AddFlushConstraint(wpProxy, faceProxy, "0""")

 

Pascal

Active Contributor
26 Posts
0 Kudos
Registered: ‎08-16-2012
Post 4 of 4

Re: Create a workplane from a face in an assembly document

11-14-2012 05:10 AM in reply to: planglais

How to do the same for a part? And how to create a workplane from a selected face? 

 

Thank you for the answer

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post