Create a work plane for a part in an assembly by a selected face VB.NET

Create a work plane for a part in an assembly by a selected face VB.NET

Anonymous
Not applicable
1,307 Views
5 Replies
Message 1 of 6

Create a work plane for a part in an assembly by a selected face VB.NET

Anonymous
Not applicable

Hi Everyone,

 

How can I can a work plane for a part in an assembly by selected face? Do I need to create a face proxy in this case?

 

2020-05-20_22h50_45.png

 

Many thanks.

Br/NgocSon

0 Likes
Accepted solutions (1)
1,308 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Normally (manually), or using code?  If using code, which do you prefer...iLogic or VBA?

 

Normally, you would go to the 3D Model tab / Work Features panel, click the drop-down under the Plane tool, choose "Offset from Plane", then click (select) the face of the part (within the assembly), then make sure the distance is set to zero, then click OK (or press Enter on the keyboard).  (I'm sure there are several other routes, and shortcuts, but that's all in personal preference.)

Yes. If you are doing this by code, then you will need to create a FaceProxy.  The proxy captures the part face data, then uses it to create an identical one at the Assembly level, so the Assembly can work with it.  If using the Pick function, just make sure you use the SelectionFilterEnum.kPartFacePlanarFilter.

Creating the FaceProxy is done from the ComponentOccurrence variable, so you will have to either select it first, or find it afterwords, from the selected face.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

J-Camper
Advisor
Advisor

From what I'm seeing here:

http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-37D27647-9CD8-4CC7-A897-14703DCD3D56

Unfortunately none of the Add Methods of the WorkPlanes Object Are supported in Assemblies, except for AddFixed, which results in an AssemblyWorkPlaneDef:

http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-741A2D4F-46CD-47B2-B958-CA0802B84F88

I don't know if that would be helpful to you or not.

 

Message 4 of 6

JhoelForshav
Mentor
Mentor
Accepted solution

Hi@Anonymous 

 

What happens in assembly documents when you add a plane with offset is that a plane is created, then constrained with a flush constraint  with offset value to the selected face/plane.

 

Try this ilogic rule to mimic the behaviour:

Sub Main
	Dim oSelectSet As SelectSet = ThisDoc.Document.SelectSet
	If oSelectSet.Count = 1
		Dim oFace = oSelectSet.Item(1)
		Dim oFaceOK As Boolean = False
		Select Case oFace.Type 'Check if selected item is planar face or workplane...
			Case ObjectTypeEnum.kFaceProxyObject, ObjectTypeEnum.kFaceObject
				If (TypeOf oFace.Geometry Is Plane) Then oFaceOK = True
			Case ObjectTypeEnum.kWorkPlaneObject, ObjectTypeEnum.kWorkPlaneProxyObject
				oFaceOK = True
		End Select
		If oFaceOK Then AddWorkPlaneInAssembly(oFace, 10) 'Input offset in documents length units
	End If
End Sub

Sub AddWorkPlaneInAssembly(oFace As Object, oOffset As Double)
	Dim uOM As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure
	Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oDef As AssemblyComponentDefinition = oAsm.ComponentDefinition
	Dim oOriginPnt As Point
	Dim oXaxis As UnitVector
	Dim oYaxis As UnitVector
	oOriginPnt = ThisApplication.TransientGeometry.CreatePoint(0#, 0#, 0#)
	oXaxis = ThisApplication.TransientGeometry.CreateUnitVector(1#, 0#, 0#)
	oYaxis = ThisApplication.TransientGeometry.CreateUnitVector(0#, 1#, 0#)
	Dim oPlane As WorkPlane = oDef.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis)
	oPlane.AutoResize = True
	oDef.Constraints.AddFlushConstraint(oFace, oPlane, uOM.ConvertUnits(oOffset, uOM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits))
	oPlane.AutoResize = False
End Sub

You'll have to have a planar face or workplane selected before running the rule 🙂

 

 

Message 5 of 6

Anonymous
Not applicable

Hello Sir,

 

I mean that I would like to create a work plane inside a part (component) by a selected face of that part in an assembly context and then will spit that part to 2 solids by that created plane (the part will become a multi-boby part).

0 Likes
Message 6 of 6

Anonymous
Not applicable

Got it!

Thanks Sir!

0 Likes