Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
chandra.shekar.g
in reply to: GeorgK

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,

 

  1. Launch Inventor 2018
  2. open new assembly document
  3. Download attached part(UCS part.ipt) to desired location
  4. Copy and paste the following VBA code into VBA editor.
  5. Update the path of part in VBA code.
  6. 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