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.
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
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.
if defined?($dc_observers)
# Open SketchUp's Dynamic Component Functions (V1) class.
# only if DC extension is active
class DCFunctionsV1
protected
# return 1 if exist and 0 if not
# Usage: = framing_exist()
def framing_exist(a_value)
if (defined?(a_value)).nil?
return 1
else
return 0
end#if
end
protected:framing_exist
end#class
end#if