- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Simplified Situation:
I have an assembly (assyDoc) which contains a UCS in 3D Space, not aligned relative to the origin at all. I would like to create a workplane, such as via AddByPlaneAndPoint, using an Assembly Origin Plane and the UCS Center Point.
What I've Tried:
I've tried using the UCS.origin, which returns a workpoint, but that errors:
var wp1 = workPlanes.AddByPlaneAndPoint(assyYZPlane, UCS.Origin);
I thought maybe the UCS origin and Center Point were not the same thing, so I tried creating a Pt using the 3 UCS planes first, but that also errors:
var centerPt = workPoints.AddByThreePlanes(UCS.XYPlane, UCS.XZPlane, UCS.YZPlane);
It feels to me like I'm missing a proxy aspect the way that it wont create work features in the assembly using the UCS items, however, you can only create proxies (as far as i am aware) using componentOccurrences, which the UCS in the assembly is not. Maybe there is something i am missing that the UCS planes are not really at the same level in the assembly as I am thinking they are, but I see no other way of utilizing them or creating proxies of them.
Thanks for any help!
Nathan
Best of Luck
---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If I remember correctly, not all plane creation method works. Some wrok in part and some work in assembly. Also what need to be passed are pretty specific type. This took some trial and error so it may not be to best solution.
This is what I use to create point and planes on COG, VS VB.net Inventor addin:
Private Sub COGUpdate()
Dim oWorkPoint As WorkPoint
Dim oWorkPlane As WorkPlane
Dim vX, vY, vZ As UnitVector
Dim oFixedDef As FixedWorkPointDef
Dim oAssPtDef As AssemblyWorkPointDef
Dim PointExist As Boolean = False
Dim COGXYExist As Boolean = False
Dim COGXZExist As Boolean = False
Dim COGYZExist As Boolean = False
Dim oDoc As Document = m_inventorApplication.ActiveDocument
Dim oCenterOfMass As Point = oDoc.ComponentDefinition.MassProperties.CenterOfMass
For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
If oWorkPoint.Name = "COG" Then
PointExist = True
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oAssPtDef = oWorkPoint.Definition
oAssPtDef.Point = oCenterOfMass
ElseIf oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
oFixedDef = oWorkPoint.Definition
oFixedDef.Point = oCenterOfMass
End If
oDoc.Update()
Exit For
End If
Next
If Not PointExist Then
oWorkPoint = oDoc.ComponentDefinition.WorkPoints.AddFixed(oCenterOfMass)
oWorkPoint.Name = "COG"
End If
vX = m_inventorApplication.TransientGeometry.CreateUnitVector(1, 0, 0)
vY = m_inventorApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
vZ = m_inventorApplication.TransientGeometry.CreateUnitVector(0, 0, 1)
For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
Select Case oWorkPlane.Name
Case "COG XY"
oWorkPlane.SetFixed(oWorkPoint.Point, vX, vY)
COGXYExist = True
'oWorkPlane.Delete()
Case "COG XZ"
oWorkPlane.SetFixed(oWorkPoint.Point, vX, vZ)
COGXZExist = True
'oWorkPlane.Delete()
Case "COG YZ"
oWorkPlane.SetFixed(oWorkPoint.Point, vY, vZ)
COGYZExist = True
Case Else
Exit Select
'oWorkPlane.Delete()
End Select
Next
If Not COGXYExist Then
oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddFixed(oWorkPoint.Point, vX, vY)
oWorkPlane.Name = "COG XY"
End If
If Not COGXYExist Then
oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddFixed(oWorkPoint.Point, vX, vZ)
oWorkPlane.Name = "COG XZ"
End If
If Not COGYZExist Then
oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddFixed(oWorkPoint.Point, vY, vZ)
oWorkPlane.Name = "COG YZ"
End If
oDoc.Update()
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks, I see now that MOST work plane (and other work feature) creation methods do not work in an assembly. Since we are pretty much left with fixed, I ended up using your approach. Here's the portions that worked for me.
Thanks Again!
UnitVector xUV = transGeo.CreateUnitVector(1, 0, 0); UnitVector yUV = transGeo.CreateUnitVector(0, 1, 0); UnitVector zUV = transGeo.CreateUnitVector(0, 0, 1);
xPlane = workPlanes.AddFixed(centerPt.Point, yUV, zUV);
zPlane = workPlanes.AddFixed(centerPt.Point, xUV, yUV);
Best of Luck
---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.