Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Orient Two UCS together

Saikiran_arakeri
Enthusiast

Orient Two UCS together

Saikiran_arakeri
Enthusiast
Enthusiast

Hi, there are two UCS in this scenario, 1. Part-CS, 2. Local-CS. I am trying to orient the LCS with the PCS and incline them in the same orientation, I am doing this so that I can perform UCS to UCS constraint. 

 

Saikiran_arakeri_0-1688706584188.png

 

The axis marked in blacked are of PCS and the other is LCS, I created the LCS at the center point of the PCS, but I am not able to orient each other. Please help. @WCrihfield @Andrii_Humeniuk @A.Acheson @JelteDeJong 

0 Likes
Reply
Accepted solutions (1)
1,620 Views
26 Replies
Replies (26)

J-Camper
Advisor
Advisor

@WCrihfield,

 

I don't think that is how a UCS works.  I can't, as a user, create constraints between an assembly UCS and the assembly's original coordinate system.  A user can only move a UCS by redefining it.  You can transform it with API, which in essence is the same as re-defining, but a UCS is a static point with vectors within the main coordinate system.

WCrihfield
Mentor
Mentor

I guess what I was thinking about was that the process of redefining an already existing UCS being similar to applying constraints, because it is being defined in relation to some other geometry, whether the native origin work features, or some other existing geometry.   And I was thinking that if it was defined according to the geometry of something in a component, that it should move with that component's geometry.  But after a bit more testing I see that is not the case.  The component can be moved after that point, and the assembly level UCS will stay where it was.

 

Here is one of my iLogic rules, using the same test assembly as I was showing above.  Just to make things interesting, I opened the second component, and redefined the custom UCS within it, so that it was not aligned with its main origin features.  Then, back in the assembly, I created this iLogic rule.  It first gets the proxy of the UCS that exists within the second part.  Then it pre-multiplies the matrix from that proxy by the matrix of the component it was within, to get the composite matrix that is accurate to the main assembly's coordinate system.  Then it sets that composite matrix as the transformation of the new assembly level UCS that it creates.  Then it creates the 3 flush constraints.  This worked OK for me in my tests, without moving anything, and without any other constraints or grounded statuses involved.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
	Dim oADoc As AssemblyDocument = ThisDoc.Document
	Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
	Dim oOcc As ComponentOccurrence = oADef.Occurrences.ItemByName("Coordinates Part 2:2")
	Dim oOccUCS As UserCoordinateSystem = oOcc.Definition.UserCoordinateSystems.Item("Part 2 UCS")
	Dim oOccUCSProxy As UserCoordinateSystemProxy = Nothing
	oOcc.CreateGeometryProxy(oOccUCS, oOccUCSProxy)
	Dim oAsmUCSDef As UserCoordinateSystemDefinition = oADef.UserCoordinateSystems.CreateDefinition
	Dim oMatrix As Inventor.Matrix = oOccUCSProxy.Transformation.Copy
	oMatrix.PreMultiplyBy(oOcc.Transformation)
	oAsmUCSDef.Transformation = oMatrix
	Dim oAsmUCS As UserCoordinateSystem = oADef.UserCoordinateSystems.Add(oAsmUCSDef)
	Dim oConstraints As AssemblyConstraints = oADef.Constraints
	oConstraints.AddFlushConstraint(oOccUCSProxy.XYPlane, oAsmUCS.XYPlane, 0)
	oConstraints.AddFlushConstraint(oOccUCSProxy.XZPlane, oAsmUCS.XZPlane, 0)
	oConstraints.AddFlushConstraint(oOccUCSProxy.YZPlane, oAsmUCS.YZPlane, 0)
End Sub

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Saikiran_arakeri
Enthusiast
Enthusiast

Hey @J-Camper, here is the file that I am testing it on. 

0 Likes

J-Camper
Advisor
Advisor

@Saikiran_arakeri,

 

The part doesn't get shared with the assembly.  Please share the part file as well.

0 Likes

Saikiran_arakeri
Enthusiast
Enthusiast

Here is the part file.

0 Likes

J-Camper
Advisor
Advisor

@Saikiran_arakeri,

 

I don't have any issues moving the assembly UCS to the part UCS using the code I posted before.  I added the constraints to the code as well and the part never moves.  I have attached a video of me running the code several times and two text files. [one matching my testing code, and the other with the testing transaction removed]

 

If you are still having issues, please let me know what version of Inventor you are using.  My testing was done in Build 359, Release 2023.3

0 Likes

Saikiran_arakeri
Enthusiast
Enthusiast

Hey guys, so I tried everything and nothing worked. So I assume there's something wrong with the assembly on my end.

0 Likes