Message 1 of 5
Get Workpoint Location in Context of Parent Assembly

Not applicable
02-24-2010
04:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm looking for help getting a part's workpoint location in context of some higher assembly. For instance, I have:
Root Assembly (center is 0,0,0)
--Assembly1 (center is 10,10,0 in relation to root)
----Part1 (center at 50,50,0 in relation to root)
In my example above, I want to get the center point of Part1 as if Assembly1 was the root assembly (this should give 40,40,0). The trick is that Assembly1 could be rotated inside its parent assembly (found it out the hard way when I realized my method was returning a negative number when it should have been positive), so it's not as easy as getting the global coordinates for Assembly1 and Part1 and subtracting Assembly1 coordinates from Part1 coordinates (basically moving the Assembly1 center point to the global center).
I thought my approach with proxies might work, but it hasn't proved too useful (maybe it's just that I'm not real familiar with how to use them).
{code}
Sub ProxyTest()
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Dim occAssy1 As ComponentOccurrence
Set occAssy1 = doc.ComponentDefinition.Occurrences(1)
Dim occAssy1Part1 As ComponentOccurrence
Set occAssy1Part1 = occAssy1.SubOccurrences(1)
Dim prxyAssy1Part1 As ComponentOccurrenceProxy
Set prxyAssy1Part1 = occAssy1Part1
Dim wpX As WorkPoint
Set wpX = prxyAssy1Part1.Definition.WorkPoints(1) 'Center Point
Dim prxyWP As WorkPointProxy
Call prxyAssy1Part1.CreateGeometryProxy(wpX, prxyWP)
Debug.Print prxyWP.Point.x, prxyWP.Point.Y, prxyWP.Point.Z
End Sub
{code}
Thanks for any help!
I'm looking for help getting a part's workpoint location in context of some higher assembly. For instance, I have:
Root Assembly (center is 0,0,0)
--Assembly1 (center is 10,10,0 in relation to root)
----Part1 (center at 50,50,0 in relation to root)
In my example above, I want to get the center point of Part1 as if Assembly1 was the root assembly (this should give 40,40,0). The trick is that Assembly1 could be rotated inside its parent assembly (found it out the hard way when I realized my method was returning a negative number when it should have been positive), so it's not as easy as getting the global coordinates for Assembly1 and Part1 and subtracting Assembly1 coordinates from Part1 coordinates (basically moving the Assembly1 center point to the global center).
I thought my approach with proxies might work, but it hasn't proved too useful (maybe it's just that I'm not real familiar with how to use them).
{code}
Sub ProxyTest()
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Dim occAssy1 As ComponentOccurrence
Set occAssy1 = doc.ComponentDefinition.Occurrences(1)
Dim occAssy1Part1 As ComponentOccurrence
Set occAssy1Part1 = occAssy1.SubOccurrences(1)
Dim prxyAssy1Part1 As ComponentOccurrenceProxy
Set prxyAssy1Part1 = occAssy1Part1
Dim wpX As WorkPoint
Set wpX = prxyAssy1Part1.Definition.WorkPoints(1) 'Center Point
Dim prxyWP As WorkPointProxy
Call prxyAssy1Part1.CreateGeometryProxy(wpX, prxyWP)
Debug.Print prxyWP.Point.x, prxyWP.Point.Y, prxyWP.Point.Z
End Sub
{code}
Thanks for any help!