sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    If statements and missing attributes

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    2 Posts 2 Posters 741 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Pete
      last edited by

      Can anyone help me out - I am trying to use an IF(,,) statement but sometimes it fails. This happens when the parent component does not contain the attribute the if statement is looking for, even when the attribute is not being executed on. For instance:

      This works:
      %(#0040BF)[Parent Component Attributes:
      Left Length = 5
      Corner Length = 10
      Is Corner = "Yes"

      SubComponent Attributes:
      Length = IF(Parent!Is Corner = "Yes",Corner Length,Left Length)]

      This doesn't work:
      %(#0080FF)[Parent Component Attributes:
      Left Length = 5
      Is Corner = "No"

      SubComponent Attributes:
      Length = IF(Parent!Is Corner = "Yes",Corner Length,Left Length)]

      I want to be able to insert the subcompnent into a variety of parent componets that all have the Is Corner attribute, but only a few have the Corner Length attribute.

      An example of the if statement failing when referenced attribute does not exist.

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Hi Pete,

        There isn't a DC function that I know of to test if an attribute exists.

        Maybe you could eliminate the IsCorner attribute, and use an "odd" value in CornerLength to indicate it is not a corner?

        Hi

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement