The function of checking the existence of the parent attribute

Hellow! Happy New Year!

I want to make a dynamic component with attributes that, if existing in the parent were used, otherwise it would be possible to specify manually.

Something like that:

How to implement?

attributExist.skp (22.9 KB)

I don’t think you can. Referring to “parent!” will yield an error (visible only as red text in component attributes display), but there is no function to detect the error.

While I haven’t been able to imagine a use case, there may be one, so a “test” for the IF function like Excel’s “ISERR” would do the job, so you might put in a feature request.

But don’t hold your breath, Dynamic Components seem to be the lowest priority for SketchUp to improve.

1 Like

May be possible to apply something like that from Ruby, but how?

Can’t help you there. My Ruby knowledge is virtually non-existent!

I have not inspected the file, yet (mostly on a phone),
But what would be a usecase?
You can always implement an IF statement, which is,somehow, the most basic error handling:
IF(PARENT!attribute, PARENT!attribute, OtherValue)

Creation of new sttributes is not possible within the DC, so you must create a custom one.
The OtherValue being a customized attribute which the user can set in the option dialog

Yes, but if the Parent!attribute does not exist, an error occurs that is not processed, the formula is highlighted in red.

And I just need to check the existence of the parent attribute …

1 Like

Ah! But what is the usecase?

Meaning in nested components…
And if there is no such attribute in the parent, then you can simply change the characteristics of the component manually.

In general, parametric components and models.

I tried this plugin:

if defined?($dc_observers)
  # Open SketchUp's Dynamic Component Functions (V1) class.
  # only if DC extension is active
class DCFunctionsV1

  # return 1 if exist and 0 if not
  # Usage: = framing_exist()
  def framing_exist(a_value)
if (defined?(a_value)).nil?
        return 1
	return 0



error: unknown function