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

Feature suppression based on handing and height

Hi Gents,

 

Could you please help me out with writing better code to handle hinge suppression based on handing and height.

My if else statement is very clunky, it works but it is not efficient, inventor freezes for 3-10min, depending, if you are changing door hand from single left hand to double right hand.

So, what I have is:

4 no. types of door hand : single left, single right, double left, double right

3 no. range of lengths to determine if 3 no. hinges is required or 4 or 5.

 

Below is my rule: If someone can point me in correct direction to utilise ilogic API, i would be very grateful.

 

If leg_top_edge < 2200 And (door_hand = "single right") Then
wp_2_hinge = (-leg_top_edge + 551) / 2 - 294

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = True
Component.IsActive("S.STEEL HINGE:2") = True
Component.IsActive("S.STEEL HINGE:3") = True
Component.IsActive("S.STEEL HINGE:4") = False
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False


Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = False
Component.IsActive("S.STEEL HINGE:7") = False
Component.IsActive("S.STEEL HINGE:8") = False
Component.IsActive("S.STEEL HINGE:9") = False
Component.IsActive("S.STEEL HINGE:10") = False




ElseIf leg_top_edge >= 2200 And leg_top_edge < 2400 And (door_hand = "single right") Then
wp_2_hinge = (-leg_top_edge + 801) / 2 - 544

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = True
Component.IsActive("S.STEEL HINGE:2") = True
Component.IsActive("S.STEEL HINGE:3") = True
Component.IsActive("S.STEEL HINGE:4") = True
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False


Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = False
Component.IsActive("S.STEEL HINGE:7") = False
Component.IsActive("S.STEEL HINGE:8") = False
Component.IsActive("S.STEEL HINGE:9") = False
Component.IsActive("S.STEEL HINGE:10") = False



ElseIf leg_top_edge >= 2400 And (door_hand = "single right") Then
wp_2_hinge = (-leg_top_edge + 1051) / 2 - 544

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = True

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = True

Component.IsActive("S.STEEL HINGE:1") = True
Component.IsActive("S.STEEL HINGE:2") = True
Component.IsActive("S.STEEL HINGE:3") = True
Component.IsActive("S.STEEL HINGE:4") = True
Component.IsActive("S.STEEL HINGE:5") = True

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False


Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = False
Component.IsActive("S.STEEL HINGE:7") = False
Component.IsActive("S.STEEL HINGE:8") = False
Component.IsActive("S.STEEL HINGE:9") = False
Component.IsActive("S.STEEL HINGE:10") = False




ElseIf leg_top_edge < 2200 And (door_hand = "single left") Then
wp_2_hinge = (-leg_top_edge+551)/2 -294

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = False
Component.IsActive("S.STEEL HINGE:2") = False
Component.IsActive("S.STEEL HINGE:3") = False
Component.IsActive("S.STEEL HINGE:4") = False
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False


Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = True
Component.IsActive("S.STEEL HINGE:7") = True
Component.IsActive("S.STEEL HINGE:8") = True
Component.IsActive("S.STEEL HINGE:9") = False
Component.IsActive("S.STEEL HINGE:10") = False



ElseIf leg_top_edge >= 2200 And leg_top_edge < 2400 And (door_hand = "single left") Then
wp_2_hinge = (-leg_top_edge + 801) / 2 - 544


Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = False
Component.IsActive("S.STEEL HINGE:2") = False
Component.IsActive("S.STEEL HINGE:3") = False
Component.IsActive("S.STEEL HINGE:4") = False
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False


Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = True
Component.IsActive("S.STEEL HINGE:7") = True
Component.IsActive("S.STEEL HINGE:8") = True
Component.IsActive("S.STEEL HINGE:9") = True
Component.IsActive("S.STEEL HINGE:10") = False



ElseIf leg_top_edge >= 2400 And (door_hand = "single left") Then
wp_2_hinge = (-leg_top_edge+1051)/2 -544

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = False
Component.IsActive("S.STEEL HINGE:2") = False
Component.IsActive("S.STEEL HINGE:3") = False
Component.IsActive("S.STEEL HINGE:4") = False
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = True


Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = True

Component.IsActive("S.STEEL HINGE:6") = True
Component.IsActive("S.STEEL HINGE:7") = True
Component.IsActive("S.STEEL HINGE:8") = True
Component.IsActive("S.STEEL HINGE:9") = True
Component.IsActive("S.STEEL HINGE:10") = True

ElseIf leg_top_edge < 2200 And (door_hand = "double left" Or door_hand = "double right") Then
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = True
Component.IsActive("S.STEEL HINGE:2") = True
Component.IsActive("S.STEEL HINGE:3") = True
Component.IsActive("S.STEEL HINGE:4") = False
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = False
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = False
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = True
Component.IsActive("S.STEEL HINGE:7") = True
Component.IsActive("S.STEEL HINGE:8") = True
Component.IsActive("S.STEEL HINGE:9") = False
Component.IsActive("S.STEEL HINGE:10") = False

wp_2_hinge = (-leg_top_edge+551)/2 - 294

ElseIf leg_top_edge >= 2200 And leg_top_edge < 2400 And (door_hand = "double left" Or door_hand = "double right") Then
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = False

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = False

Component.IsActive("S.STEEL HINGE:1") = True
Component.IsActive("S.STEEL HINGE:2") = True
Component.IsActive("S.STEEL HINGE:3") = True
Component.IsActive("S.STEEL HINGE:4") = True
Component.IsActive("S.STEEL HINGE:5") = False

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = False	

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = False

Component.IsActive("S.STEEL HINGE:6") = True
Component.IsActive("S.STEEL HINGE:7") = True
Component.IsActive("S.STEEL HINGE:8") = True
Component.IsActive("S.STEEL HINGE:9") = True
Component.IsActive("S.STEEL HINGE:10") = False

wp_2_hinge = (-leg_top_edge + 801) / 2 - 544

ElseIf leg_top_edge >= 2400 And (door_hand = "double left" Or door_hand = "double right") Then
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_rh:5") = True

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:1") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:2") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:3") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:4") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:5") = True

Component.IsActive("S.STEEL HINGE:1") = True
Component.IsActive("S.STEEL HINGE:2") = True
Component.IsActive("S.STEEL HINGE:3") = True
Component.IsActive("S.STEEL HINGE:4") = True
Component.IsActive("S.STEEL HINGE:5") = True

Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:1") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:2") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:3") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:4") = True
Feature.IsActive("FRAME MASTER PART:2", "frame_hinge_prep_lh:5") = True	

Component.IsActive("FRAME HINGE PLATE ASSEMBLY:6") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:7") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:8") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:9") = True
Component.IsActive("FRAME HINGE PLATE ASSEMBLY:10") = True

Component.IsActive("S.STEEL HINGE:6") = True
Component.IsActive("S.STEEL HINGE:7") = True
Component.IsActive("S.STEEL HINGE:8") = True
Component.IsActive("S.STEEL HINGE:9") = True
Component.IsActive("S.STEEL HINGE:10") = True

wp_2_hinge = (-leg_top_edge + 1051) / 2 - 544


End If


'iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()

 

 

 

It's hard to say for sure without seeing the model, but it looks like you should be able to change your assembly to use Component Patterns, and then use a user parameter to change the number and/or the spacing of things (either using an iLogic form or a Rule). That should speed things up for you.

 

If you can't switch to patterns then you could look into writing functions to simplify your code and using user parameters to control the suppression states of different objects but I'm not sure if that would be faster or not.