USC to USC I-Logic

USC to USC I-Logic

regerk
Explorer Explorer
546 Views
2 Replies
Message 1 of 3

USC to USC I-Logic

regerk
Explorer
Explorer

Hi,

 

I replace assemblies with I-Logic. The coded worked when I place the Rule directly in the assembly I like to change.

I try to move the rule in an assembly one level higher, because I like later to edit more sub assemblies with one Forms.

 

For both codes I get this error message. The error message is only for "Constraints.AddUcsToUcs" . "Constraints.Delete" doesn't work but I get no error message.

 

Error in rule: RAILING_FRONT_1, in document: 1472586_IAM_000.iam

Constraints.AddUcsToUcs("Railing holder left", "CS_EIN") : The component named "Railing holder left" was not found.

 

More Information TAB

System.ArgumentException: Constraints.AddUcsToUcs("Railing holder left", "CS_EIN") : The component named "Railing holder left" was not found.
at iLogic.CadAssemblyUtil.FindComponent(Document rootDoc, ComponentArgument comp, String visibleCallerName, String entityName)
at Autodesk.iLogic.Runtime.InventorEntities.UcsFinder.GetUcs(Document document, ComponentArgument component, String ucsName, String visibleCallerName)
at Autodesk.iLogic.Core.ManagedAssembly.UcsToUcsConstraintFactory..ctor(ManagedConstraints managedConstraints, String constraintName, String[] linkedConstraintNames, ComponentArgument component1, String ucsName1, ComponentArgument component2, String ucsName2, Object[] offsets)
at iLogic.ManagedConstraints.AddUcsToUcs(String constraintName, ComponentArgument component1, String ucsName1, ComponentArgument component2, String ucsName2, Object xOffset, Object yOffset, Object zOffset, String[] linkedConstraintNames)
at ThisRule.KorlattartoModositas()
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

	
		Select Case PA_GL1_RAILING_HOLDER
	
		Case "FIXED"
			Component.Replace("Railing holder left", defaultPath & "/1264067_IAM_000.iam", True)		

'			USC delete and create
			Constraints.Delete("CS_EINtoCS_AN_LEFT")
			Constraints.Delete("CS_EINtoCS_AN_LEFT_XZ")
			Constraints.Delete("CS_EINtoCS_AN_LEFT_YZ")
			Constraints.AddUcsToUcs("CS_EINtoCS_AN_LEFT", "Railing holder left", "CS_EIN", "RAILING_FRONT_1", "CS_AN_LEFT", 
                           xOffset := 0, yOffset := 0, zOffset := 0)

 

	Select Case PA_GL1_RAILING_HOLDER
	
		Case "FIXED"
			Component.Replace("Railing holder left", defaultPath & "/1264067_IAM_000.iam", True)		

'			USC delete and create
			Constraints.Delete("CS_EINtoCS_AN_LEFT")
			Constraints.Delete("CS_EINtoCS_AN_LEFT_XZ")
			Constraints.Delete("CS_EINtoCS_AN_LEFT_YZ")
			Constraints.AddUcsToUcs("CS_EINtoCS_AN_LEFT", "Railing holder left", "CS_EIN", "", "CS_AN_LEFT", 
                           xOffset := 0, yOffset := 0, zOffset := 0)

I also tried to write the assembly name into the "Constraints.AddUcsToUcs" command

			Constraints.AddUcsToUcs("CS_EINtoCS_AN_LEFT", "RAILING_FRONT_1/Railing Holder left", "CS_EIN", "RAILING_FRONT_1", "CS_AN_LEFT", 
                            xOffset := 0, yOffset := 0, zOffset := 0)

 

Is there a option to select the "root" assembly for the complete I-Logic Rule? Or do I have an error in my command lines?

0 Likes
547 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

I think your just not providing the correct input into the Constraints.AddUcsToUcs() function.

You're using:

Constraints.AddUcsToUcs("CS_EINtoCS_AN_LEFT", "Railing holder left", "CS_EIN", "RAILING_FRONT_1", "CS_AN_LEFT", 0, 0, 0)

You should replace "Railing holder left" with the component object, instead of its String name.  Same for the second component.  Within the function's pop-up message it is asking for a ComponentArgument, but you can substitute a regular ComponentOccurrence object in its place.

Also, it looks like you just replaced the "Railing holder left" component above that position with another component.  Then you're still trying to apply a constraint to a component of the same name as the one you just replaced.  Are you sure this is right?  It seems like the component you're placing a UcsToUcs constraint on below, would be a different component, but I could be wrong.

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

regerk
Explorer
Explorer

I use the string name, because I have three different assemblies for left and right and with the string name it's possible to have the same name if my document version in the database would change. 

To switch the parts I use the comonent.replace and that is working

 

			Component.Replace("Railing holder left", defaultPath & "/1264067_IAM_000.iam", True)	

 

 

0 Likes