- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been trying to get this piece of code to work:
oDef = ThisDoc.Document.ComponentDefinition Dim oWPlane As WorkPlane Dim oAxis As WorkAxes oAxis = oDef.WorkAxes oWPlane = oDef.WorkPlanes.AddByLinePlaneAndAngle(oDef.WorkPlanes("XY Plane"), oAxis("Y Axis"), 45) oWPlane.Name = "Plane_Name"
I found it on these forums but it doesn't seem to work in 2023 Inventor. Does anyone know what needs to be adjusted to make it function now?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You've put in the axis and the plane in the wrong order...
This should work:
Dim oDef = ThisDoc.Document.ComponentDefinition Dim oWPlane As WorkPlane Dim oAxis As WorkAxes oAxis = oDef.WorkAxes oWPlane = oDef.WorkPlanes.AddByLinePlaneAndAngle(oAxis("Y Axis"), oDef.WorkPlanes("XY Plane"), 45) oWPlane.Name = "Plane_Name"
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I had already tried flipping it around but ended up with an "Unspecified error" in line 5 of the code.
I know it's not much to go on, which is why I came looking for help. I know this should be easily doable but for some reason, it isn't.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @Guthery1 . Unfortunately, this method does not work for assemblies.
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Any ideas on how we can make it work? I find it hard to believe that Autodesk made it so you can't create a plane with i-Logic in an assembly but left the ability to make planes other ways with i-Logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can create a fixed plane, here is an example:
Dim oDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oWPlane As WorkPlane
Dim oAxis As WorkAxes
oAxis = oDef.WorkAxes
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, 1) '45 deg
oYaxis = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
oWPlane = oDef.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis)
oWPlane.Name = "Plane_Name"
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If you look at what actually happens when you create a plane by line, plane and angle in an assembly, it adds a plane and then it adds a mate constraint to the line and an angle constraint to the plane. You can write your own function to mimic this behaviour.
See example below:
Sub Main
Dim yAxis As WorkAxis = ThisDoc.Document.ComponentDefinition.WorkAxes("Y Axis")
Dim YZPlane As WorkPlane = ThisDoc.Document.ComponentDefinition.WorkPlanes("YZ Plane")
Dim oWPlane As WorkPlane = AddPlaneByLinePlaneAndAngle(yAxis, YZPlane, 45)
oWPlane.Name = "Plane_Name"
End Sub
Function AddPlaneByLinePlaneAndAngle(_line As Object, _plane As Object, _angle As Double) As WorkPlane
Dim oAsm As AssemblyDocument = ThisDoc.Document
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.AddMateConstraint(_line, oPlane, 0, InferredTypeEnum.kInferredLine, InferredTypeEnum.kNoInference)
Dim oAngleConstraint As AngleConstraint = oDef.Constraints.AddAngleConstraint(_plane, oPlane, 0, AngleConstraintSolutionTypeEnum.kDirectedSolution)
oAngleConstraint.Angle.Expression = _angle.ToString
oPlane.AutoResize = False
ThisDoc.Document.Update
Return oPlane
End Function
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report