Message 1 of 2
Usings Strings to Reduce Code Line Count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I am trying to learn to use Inventor (iLogic). I've had reasonable success to date in generally Googling my questions.
One of my colleagues has seen the code I've written and tried to help me to reduce the quantity of repetitive similar statements my using strings (which is new to me).
What I had been writing is shown below but single rules have exceeded 5k lines (very small example below;
If AS_DIA = 900 Then Component.IsActive("STD-PT-038-014-POS-M:1")= False
If AS_DIA = 900 Then Component.IsActive("STD-PT-038-014-POS-N:1")= False
If AS_DIA = 900 Then Component.IsActive("STD-PT-038-014-POS-O:1")= False
If AS_DIA = 900 Then Component.IsActive("STD-PT-038-014-POS-P:1")= False
If AS_DIA = 1200 Then Component.IsActive("STD-PT-038-014-POS-M:1")= False
If AS_DIA = 1200 Then Component.IsActive("STD-PT-038-014-POS-N:1")= False
If AS_DIA = 1200 Then Component.IsActive("STD-PT-038-014-POS-O:1")= False
If AS_DIA = 1200 Then Component.IsActive("STD-PT-038-014-POS-P:1") = False
He gave me an example to get me started but I am unable to get it to work. I keep getting the error "Property access must assign to the property or use its value." I have researched this but can't find a helpful example to guide me. Below is the code I am having trouble with;
Sub Main Component.IsActive(SetAsFalse As String [])
For Each oString As String In SetAsTrue
Component.IsActive(oString) = True
Next
For Each oString As String In SetAsFalse
Component.IsActive(oString) = False
Next
If AS_DIA = 750 Then Component.IsActive (SetAsTrue = {""},SetAsFalse = {"STD-PT-038-014-POS-M:1","STD-PT-038-014-POS-N:1","STD-PT-038-014-POS-O:1","STD-PT-038-014-POS-P:1"})
End Sub
Any help/ guidance would be really appreciated
Best Regards