10-30-2017
04:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-30-2017
04:49 AM
Hi @GeorgK,
In order to copy UCS from part to assembly, UserCoordinateSystemProxy can be created from part and copied into AssemblyDocument.
To illustrate the same,
- Launch Inventor 2018
- open new assembly document
- Download attached part(UCS part.ipt) to desired location
- Copy and paste the following VBA code into VBA editor.
- Update the path of part in VBA code.
- On running the code, a UCS will be copied from part to assembly.
Sub Main()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim occMatrix As Matrix
Set occMatrix = ThisApplication.TransientGeometry.CreateMatrix
Dim occ As ComponentOccurrence
Set occ = oDef.Occurrences.Add("Path of part files\UCS part.ipt", occMatrix)
Dim compDef As PartComponentDefinition
Set compDef = occ.Definition
Dim partUCS As UserCoordinateSystem
Set partUCS = compDef.UserCoordinateSystems.Item(1)
Dim oProxy As UserCoordinateSystemProxy
Call occ.CreateGeometryProxy(partUCS, oProxy)
Dim oMatrix As Matrix
Set oMatrix = oProxy.Transformation
Dim oUCSDef As UserCoordinateSystemDefinition
Set oUCSDef = oDef.UserCoordinateSystems.CreateDefinition
oUCSDef.Transformation = oMatrix
Dim oUCS As UserCoordinateSystem
Set oUCS = 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
