Multi value list code for “0”

Multi value list code for “0”

sattju
Enthusiast Enthusiast
651 Views
6 Replies
Message 1 of 7

Multi value list code for “0”

sattju
Enthusiast
Enthusiast

I’m fairly new to Ilogic and I can do some basic configuration, but I’m running into a problem that has me completely stumped. I have a shelf that I’m using for a cabinet with multi values of 0 and 1. I’ve managed to configure the values for 1, but I’m not sure how to set the configuration values for 0. Basically, it just wouldn’t be in the assembly when I set the value to 0. I’ve tried component delete and pattern delete, but they completely erase it from my assembly when I still need it for the value of 1. Also, if anyone could assist me with whether or not there is a code to enter for specific drawer gap size that would be great as well! Any help would be appreciated!

0 Likes
Accepted solutions (1)
652 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

In your code, when the value of that parameter is found to be zero (0), instead of deleting the component or pattern, you could either suppress it or simply turn its visibility off.

Suppression status is saved within Level of Detail representations (LevelOfDetailRepresentations, LevelOfDetailRepresentation) prior to 2022, and in ModelStates in 2022 Inventor, so that option is slightly more complicated.  The visibility status is saved in a Design View Representation (DesignViewRepresentations , DesignViewRepresentation).

You could also use a Boolean (Yes/No or True/False) type user parameter, instead of a unit-less numerical parameter with 0 or 1 values.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

A.Acheson
Mentor
Mentor

If you delete the components on “0” you will need to add them back in on “1”. 
If your familiar with capture current state this will show what has been done to constrain this part and how it is referenced. Use add component reference and translate the data to match. 

Here is a helpful code snippet run down.

For the gap size if you supply some images of your workflow the answer will be more targeted. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 7

sattju
Enthusiast
Enthusiast

I have attached an image of the cabinet that has the gaps that I was referring to. I would like to code it to where I can enter in the number of dividers as well as type in the spacing of each gap. We do a lot of cabinet millwork and of course not all cabinets are the same and a lot of our designs are custom made.

 

As far as the elimination of the shelf for "0", I believe the "this assembly...end assembly" is what I'm looking for. I'll have to play around with it and see if I can code it correctly. I did try view representations, but I'm not sure if I coded it correctly for it to have worked.

 

Here is the code that I working with for the shelf. It's very choppy so go easy on me! I'm still learning!

 

'SHELF
Dim OCOMPDEF As ComponentDefinition
ODOC = ThisApplication.ActiveDocument
OCOMPDEF = ODOC.COMPONENTDEFINITION


Select Case SHELF_QTY

Case "0"
	If SHELF_QTY = "0" Then
	OCOMPDEF.REPRESENTATIONSMANAGER.DESIGNVIEWREPRESENTATIONS.ITEM("NO SHELF").ACTIVATE
	End If
	

Case "1"
	OCOMPDEF.REPRESENTATIONSMANAGER.DESIGNVIEWREPRESENTATIONS.ITEM("DEFAULT").ACTIVATE
	d33 = "1"
	If HEIGHT = "18" Then
		SHELF_GAP = "8.625"
	Else If HEIGHT = "24" Then
		SHELF_GAP = "11.625"
	Else If HEIGHT = "30" Then
		SHELF_GAP = "14.625"
	Else If HEIGHT = "33" Then
		SHELF_GAP = "16.125"
	Else If HEIGHT = "34.5" Then
		SHELF_GAP = "16.875"
	Else If HEIGHT = "36" Then
		SHELF_GAP = "17.625"
	End If
End Select
0 Likes
Message 5 of 7

A.Acheson
Mentor
Mentor
Accepted solution
Are you going for an accurate BOM? If so using the visibility will give the appropriate drawing but not the BOM, the qty’s will show for all parts in the model regardless of been visible or not. So either use level of detail or delete. Level of detail is a little complex and has undergone changes in 2022. I don’t personally use it choosing to remove parts instead. 

For the shelf drawer you could probably use another case statement as it is less to write than the if/else if statements.

For the shelf sizing if this is all fixed you are on the right track I would think. Another way would be to write a formula in the code/ parameter to work out the spacing using the pattern qty’s shelf thickness and space to fill. 

Regarding the code try and use proper case for the API code as it is what is common, I think VBA would enforce its use as it is case sensitive but vb.net which is what ilogic is ran through is not .

Here is a link to the API user manual. It is also built into the help section of the software. Since your using the API for the view rep you may need additional help/ figure out where the forum post information comes from. The ilogic snippets are effectively sections of code/functions from the API which are shortened using more descriptive names. 
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 7

sattju
Enthusiast
Enthusiast

Understood. I did manage to figure out the "0" multivalue code so I am good there. I will take a look at this API manual and see what I can find. Thanks for all of your help!

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

Just a counter note about BOM accuracy thing.  It's true that simply turning visibility of components on/off won't change things within the assembly's BOM, but the view representation can be used to filter a parts lists in a drawing.  And the main purpose of the level of detail representations (prior to Inventor 2022's ModelStates), was for performance, because it saved the 'suppression' states of components.  And when you have components suppressed, they aren't loaded into memory, which makes the assembly open and perform faster.  There is a property specifically for effecting how the component is seen/understood in the assembly's BOM.  The ComponentOccurrence object (as well as PartComponentDefinition & AssemblyComponentDefinition) has a property called "BOMStructure" which has a value from BOMStructureEnum.  Setting this will directly effect how the component (or Part or Assembly) are understood by the BOM.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes