coding ilogic - what if it's not there?

coding ilogic - what if it's not there?

Anonymous
Not applicable
357 Views
2 Replies
Message 1 of 3

coding ilogic - what if it's not there?

Anonymous
Not applicable

I imported a step file assembly & created a rule to change the imported parts colour (seen as 'Base1' in the browser) for example:

 

If iProperties.Material = "Steel, Mild" Then Feature.Color("Base1")= "Dark Olive"
If iProperties.Material = "St/St 304" Then Feature.Color("Base1")= "Cadet Blue"

 

I'd like to adpat the code to run on other parts - normal parts don't  contain 'Base1' & a not found error is generated.

 

The question is, what is the code to ignore something if it isn't there?

I'm thinking 

If iProperties.Material = "Steel, Mild" Then Feature.Color("Base1")= "Dark Olive" Or Component.Color("PartA:1")= "Dark Olive"

but the part is new, may or may not of been saved so it's not identified as 'PartA:1'......

 

Whatever the lump on screen is, I just want to pick a radio button, assign a colour & custom ipropert ( in this case Thk) - this is the existing code for imported step file parts:

 

booleanParam = InputRadioBox("Prompt", "Steel, Mild", "St/St 304", booleanParam, Title := "Title")
If booleanParam = "True" Then iProperties.Material = "Steel, Mild" Else iProperties.Material = "St/St 304"
thk = InputBox("Thk Value", "", "Thk Value")
numerical_value = CDbl(thk)
iProperties.Value("Custom", "Thk")=Round(numerical_value, 1)
If iProperties.Material = "Steel, Mild" Then Feature.Color("Base1")= "Dark Olive" Or Component.Color("PartA:1")= "Dark Olive"
If iProperties.Material = "St/St 304" Then Feature.Color("Base1")= "Cadet Blue"

 

Thanks

 

Andrew

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

Anonymous
Not applicable
temporary fix:
booleanParam = InputRadioBox("Prompt", "Steel, Mild", "St/St 304", booleanParam, Title := "Title")
If booleanParam = "True" Then iProperties.Material = "Steel, Mild" Else iProperties.Material = "St/St 304"
thk = InputBox("Thk Value", "", "Thk Value")
numerical_value = CDbl(thk)
iProperties.Value("Custom", "Thk")=Round(numerical_value, 1)
If iProperties.Material = "Steel, Mild" Then iProperties.PartColor= "Dark Olive"
If iProperties.Material = "St/St 304" Then iProperties.PartColor= "Cadet Blue"
0 Likes
Message 3 of 3

Owner2229
Advisor
Advisor

Hi, you can use this:

 

'code that wont throw errors
Try
    'some code that may cause errors
Catch
'code that will run when an error in the code above occurs, can be left empty ofc. End Try 'code that wont throw errors
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes