iLogic: Using a shared variable value to suppress constraints

iLogic: Using a shared variable value to suppress constraints

ian_solomon
Contributor Contributor
994 Views
3 Replies
Message 1 of 4

iLogic: Using a shared variable value to suppress constraints

ian_solomon
Contributor
Contributor

I am trying to set the suppression state of a constraint based on a shared variable value, and it just does not seem to work. I have renamed the constraint to "Cap", and the shared variable is called "CHSS".

The three values of this variable are: "NG250_WS_RH", "NG250_WS_LH", and "NG250_WS_NIL".

 

This is the code I am using:

'Set Cap constraint
If SharedVariable("CHSS") = ("NG250_WS_RH") Then
	Constraint.IsActive("Cap")= True
ElseIf SharedVariable("CHSS") = ("NG250_WS_LH") Then 
	Constraint.IsActive("Cap") = True
ElseIf SharedVariable("CHSS") = ("NG250_WS_NIL") Then 
	Constraint.IsActive("Cap") = False	
End If

 I have also tried this:

'Set Cap constraint
If SharedVariable("CHSS") = "NG250_WS_RH" Then
	Constraint.IsActive("Cap")= True
ElseIf SharedVariable("CHSS") = "NG250_WS_LH" Then 
	Constraint.IsActive("Cap") = True
ElseIf SharedVariable("CHSS") = "NG250_WS_NIL" Then 
	Constraint.IsActive("Cap") = False	
End If

What do I have wrong?

0 Likes
Accepted solutions (2)
995 Views
3 Replies
Replies (3)
Message 2 of 4

blandb
Mentor
Mentor

what if you remove the () from NG250... in you if then statement

Autodesk Certified Professional
Message 3 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi ian.solomon ,

 

I did a quick test and it seemed to work as written.

 

Here is a quick example you can use to test. This example sets the shared variable with an listbox, and then suppress the constraint depending upon the what is selected. 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oCHSS_options = New String(){"NG250_WS_RH", "NG250_WS_LH","NG250_WS_NIL" }

SharedVariable("CHSS") = _
InputListBox("Prompt", oCHSS_options, SharedVariable("CHSS"), _
"iLogic", "CHSS Options")


'Set Cap constraint
If SharedVariable("CHSS") = ("NG250_WS_RH") Then
	Constraint.IsActive("Cap")= True
ElseIf SharedVariable("CHSS") = ("NG250_WS_LH") Then 
	Constraint.IsActive("Cap") = True
ElseIf SharedVariable("CHSS") = ("NG250_WS_NIL") Then 
	Constraint.IsActive("Cap") = False	
End If

EESignature

Message 4 of 4

ian_solomon
Contributor
Contributor
Accepted solution

I'm gonna seem like a dufus, but it was working. I was just calling up the wrong shared variable... doh!!

 

Thanks for the help anyway.

Ian