11-12-2017
08:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-12-2017
08:21 PM
Hi @GeorgK,
You could try the following VBA code. Here, only part occurrences are considered.
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 occDef As ComponentDefinition
Set occDef = oUCS.Parent
Dim occ As ComponentOccurrence
Dim occMatrix As Matrix
For Each occ In oDef.Occurrences.AllLeafOccurrences
If occ.Definition Is occDef Then
Set occMatrix = occ.Transformation
Exit For
End If
Next
If occMatrix Is Nothing Then
Debug.Print ("UCS occurrence not found")
Else
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 If
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
