11-08-2017
12:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-08-2017
12:45 AM
Hi @GeorgK,
Try the following VBA code to copy UCS from part to assembly. Here, location of part occurrence plays important role in copying UCS. So, occurrence selection is required to copy UCS.
Sub Main()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim oUCS As UserCoordinateSystem
Set oUCS = ThisApplication.CommandManager.Pick(kUserCoordinateSystemFilter, "Select UCS")
Dim occ As ComponentOccurrence
Set occ = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select occurrence from which UCS need to copy")
Dim occMatrix As Matrix
Set occMatrix = occ.Transformation
Dim oMatrix As Matrix
Set oMatrix = oUCS.Transformation
Call oMatrix.TransformBy(occMatrix)
Dim oUCSDef As UserCoordinateSystemDefinition
Set oUCSDef = oDef.UserCoordinateSystems.CreateDefinition
oUCSDef.Transformation = oMatrix
Dim copiedUCS As UserCoordinateSystem
Set copiedUCS = oDef.UserCoordinateSystems.Add(oUCSDef)
End Sub
Please feel free to contact if there is any queries.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
