Hi,
I currently want to use iLogic to create offset planes from the origin in an assembly. Is this possible? If not what's the next easiest option?
I use the below code in .ipt without issues and don't know enough about iLogic to know why this doesn't work 😥
oDef = ThisDoc.Document.ComponentDefinition Dim oWPlane As WorkPlane oWPlane = oDef.WorkPlanes.AddByPlaneAndOffset(oDef.WorkPlanes("XY Plane"), 20 mm) oWPname = "My_New_Work_Plane"
Any help much appreciated.
Solved! Go to Solution.
Hi,
I currently want to use iLogic to create offset planes from the origin in an assembly. Is this possible? If not what's the next easiest option?
I use the below code in .ipt without issues and don't know enough about iLogic to know why this doesn't work 😥
oDef = ThisDoc.Document.ComponentDefinition Dim oWPlane As WorkPlane oWPlane = oDef.WorkPlanes.AddByPlaneAndOffset(oDef.WorkPlanes("XY Plane"), 20 mm) oWPname = "My_New_Work_Plane"
Any help much appreciated.
Solved! Go to Solution.
Solved by JhoelForshav. Go to Solution.
A work backward’s approach could work here. Create the offset plane as normal and then enter your rule and find the offset plane and use capture snippet. This will allow you to create the ilogic required.
http://www.inventortales.com/2013/03/using-capture-current-state-with.html?m=1
On further investigation your above code will only work to create a workplane but not offset it. The below link shows you how. You could also search the API help to get the most current example of this as it may have been changed since 2018.
What inventor version have you got?
A work backward’s approach could work here. Create the offset plane as normal and then enter your rule and find the offset plane and use capture snippet. This will allow you to create the ilogic required.
http://www.inventortales.com/2013/03/using-capture-current-state-with.html?m=1
On further investigation your above code will only work to create a workplane but not offset it. The below link shows you how. You could also search the API help to get the most current example of this as it may have been changed since 2018.
What inventor version have you got?
Hi @will_roe
The only way to add a workplane in assembly environment by iLogic/API is to add a fixed plane. For example AddPlaneAndOffset doesn't work. If you have a look at a workplane created that way (manually) in an assembly, you'll see that a plane is created and then constrained with a Flush constraint with offset.
You can do this by code, but not using AddByPlaneAndOffset.
Try this 🙂
Sub Main oDef = ThisDoc.Document.ComponentDefinition Dim oWPlane As WorkPlane oWPlane = AddWorkPlaneInAssemblyOffset(oDef.WorkPlanes("XY Plane"), 20) oWPlane.Name = "My_New_Work_Plane" End Sub Function AddWorkPlaneInAssemblyOffset(oFace As Object, oOffset As Double) As WorkPlane 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 Return oPlane End Function
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Hi @will_roe
The only way to add a workplane in assembly environment by iLogic/API is to add a fixed plane. For example AddPlaneAndOffset doesn't work. If you have a look at a workplane created that way (manually) in an assembly, you'll see that a plane is created and then constrained with a Flush constraint with offset.
You can do this by code, but not using AddByPlaneAndOffset.
Try this 🙂
Sub Main oDef = ThisDoc.Document.ComponentDefinition Dim oWPlane As WorkPlane oWPlane = AddWorkPlaneInAssemblyOffset(oDef.WorkPlanes("XY Plane"), 20) oWPlane.Name = "My_New_Work_Plane" End Sub Function AddWorkPlaneInAssemblyOffset(oFace As Object, oOffset As Double) As WorkPlane 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 Return oPlane End Function
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
This was exactly what I was looking for! Much appreciated!
This was exactly what I was looking for! Much appreciated!
@JhoelForshav please don't mind me asking what is the reason behind not allowing to add a plane by AddByPlaneAndOffset in an assembly?
@JhoelForshav please don't mind me asking what is the reason behind not allowing to add a plane by AddByPlaneAndOffset in an assembly?
@JhoelForshav Thanks for this code, was able to tweak it to work with my existing VBA code after few glitches.
@JhoelForshav Thanks for this code, was able to tweak it to work with my existing VBA code after few glitches.
Can't find what you're looking for? Ask the community or share your knowledge.