Dynamic Component Naming based on Attributes

Hi all

I’ve created a series of dynamic kitchen cabinets and wanted to generate Naming based on the user input sizes for width and height. Guessing it’s as simple text function but can seem to find it. Basically looking to then be able to have tags in layout that would populate auto text and let me quickly add notes to plan sets

Cheers

Mark

Sounds like perhaps the CHOOSE function ?

from the DC User Guide: Supported Functions page

CHOOSE(index,value1,value2, ...valueN)
The CHOOSE function returns a value from a list of parameters at the location of the index value. This function allows you to create a single drop-down list that drives multiple attribute changes at once.

Example:

=CHOOSE(2,"Blue","Red","Green")

The previous example results in “Red.”

Use CHOOSE and OPTIONINDEX together as a mechanism to assign different values depending on a user’s choice in the Component Options dialog box. For example, if the Component Options dialog box allows the user to choose different materials to assign to a component (and the price changes depending on material chosen), the formula for MSRP might be:

=CHOOSE (OPTIONINDEX("Material"), 100, 150, 200)

The previous example returns 100, 150, or 200 depending on the material chosen in the Component Options dialog box.

Maybe concatenate?

Before using the “Name” attribute you need to consider if the user will be using the instance name, as changes to the instance can be reflected in both the attribute and option dialog forms. The “Name” attribute over rides this functionality

I’ve been working on the same issue. It’s no problem to generate a “Component Info Name” by any means. But there is no way to replace the “Component Definition” with the “Component Info Name”. So when you go to Layout and use the Label tool, you only get to select an “Entity Name”.

You have to physically replace the “Component Definition” with your desired name for the Label tool in Layout to work.

Generate Report at Level 2 will work for pulling “Component Info Name” .

The Label tool in LayOut is perfectly capable of displaying the contents of any custom component attribute you have defined.

I recommend you use the “component instance” name which means you do not use the “name” attribute, however you can reference _name to get the original definition if required in attribute formulas.
It must be noted that the automatic changes and updates happen only after the DC is saved and inserted into a file.
Use component definition as a general term like beam, panel…

1 Like


I’d be very excited to discover the gap in my thinking.


Delete the name Attribute in the DC then put a value in the instance, you will find the option name and attribute dialog will follow suit, then in layout it will be available too.
Any attribute should be available in layout provided you expose it in the option dialog
boards grain on X test.skp (572.9 KB)

As per the attached file change any instance and see how it updates, see report attached to file as well

3 Likes


Now I’m excited. Never once, did I ever, click on CAB BLANK#1 to reveal the “Choose Label Text” list on the right. btw I didn’t have to delete the DC name attribute or put a value in the instance. It worked as is.

I humbly submit myself for a page in the next “Doh” handbook. Thank You

3 Likes

I think we all deserve a mention in the “doh!” book, there is always some treasure to be discovered in Sketchup, it is its simplistic face with complexity under the surface.

You can use the Name attribute, but it disables the connection of the instance naming to all parts of a project, I believe an under used gem. However there is no set way to model, neither should there be, another good aspect of Sketchup

2 Likes

Thanks all for your help, wonder how I can now get it to generate a name based on the custom attributes selected.

For example; if I select 36" for cabinet width and 30" for height, is there a way to generate a component name of BCab_36_30 in the dynamic component name attribute that would then be selected form Label text in Layout

@markunderkover

use concatenate function in the Name field.
=concatenate(“BCab_”,CabWidth,“_”,CabHeight)

1 Like