Jump to content

Concatenating strings in a part


Go to solution Solved by Ashley,

Recommended Posts

We are looking to generate a "notification" part that we can use in an exporter. We've purchased a measuring table, and there's a spot in the table for a user popup. Our goal is to set this to popup on doors with hinge drilling, custom info, etc. This is what I've attempted:
 

text
(
    custom_info +
    (
        hinge_drilling.id != 0 ?
        (
            text("This door requires hinge drilling : ")
            + text(hinge_drilling.name)
        )
        : text("")
    )
)

However, it just throws a string of errrors when I try to save. Is there a way to combine multiple strings in a part?

Link to comment
Share on other sites

I used the power of AI to generate a formula, but this only handles two of the options that I need to split out - I fear that it will get overly complex!
 

/* Check if hinge drilling is selected */
(hinge_drilling == 0
  /* If hinge_drilling is not selected, move to check rustic treatment */
  ? (rustic_treatment.id == 0 
      /* If no rustic treatment is selected, output "No hinge drilling or rustic treatment required." */
      ? text("No hinge drilling or rustic treatment required.") 
      /* Otherwise, check which rustic treatment is selected */
      : (rustic_treatment.id == 1 
        /* If wire brushing is selected */
        ? text("No hinge drilling required. This door needs rustic treatment: wire brushing") 
        : (rustic_treatment.id == 2 
          /* If circle sawn is selected */
          ? text("No hinge drilling required. This door needs rustic treatment: circle sawn") 
          : (rustic_treatment.id == 3 
            /* If rough sawn is selected */
            ? text("No hinge drilling required. This door needs rustic treatment: rough sawn") 
            /* If circle sawn is selected */
            : text("No hinge drilling required. This door needs rustic treatment: circle sawn")))))
  /* If hinge_drilling is selected, check which side is selected */
  : (hinge_drilling == 1
    /* If left side is selected, move to check rustic treatment */
    ? (rustic_treatment.id == 0 
      /* If no rustic treatment is selected */
      ? text("This door needs hinge drilled on the left side. No rustic treatment required.") 
      /* Otherwise, check which rustic treatment is selected */
      : (rustic_treatment.id == 1 
        /* If wire brushing is selected */
        ? text("This door needs hinge drilled on the left side and rustic treatment: wire brushing") 
        : (rustic_treatment.id == 2 
          /* If circle sawn is selected */
          ? text("This door needs hinge drilled on the left side and rustic treatment: circle sawn") 
          : (rustic_treatment.id == 3 
            /* If rough sawn is selected */
            ? text("This door needs hinge drilled on the left side and rustic treatment: rough sawn") 
            /* If circle sawn is selected */
            : text("This door needs hinge drilled on the left side and rustic treatment: circle sawn"))))
    /* If right side is selected for hinge drilling, move to check rustic treatment */
    : (hinge_drilling == 2
      /* Check rustic treatment */
      ? (rustic_treatment.id == 0 
        /* If no rustic treatment is selected */
        ? text("This door needs hinge drilled on the right side. No rustic treatment required.") 
        /* Otherwise, check which rustic treatment is selected */
        : (rustic_treatment.id == 1 
          /* If wire brushing is selected */
          ? text("This door needs hinge drilled on the right side and rustic treatment: wire brushing") 
          : (rustic_treatment.id == 2 
            /* If circle sawn is selected */
            ? text("This door needs hinge drilled on the right side and rustic treatment: circle sawn") 
            : (rustic_treatment.id == 3 
              /* If rough sawn is selected */
              ? text("This door needs hinge drilled on the right side and rustic treatment: rough sawn") 
              /* If circle sawn is selected */
              : text("This door needs hinge drilled on the right side and rustic treatment: circle sawn"))))
      /* If a pair is selected for hinge drilling, move to check rustic treatment */
      : (rustic_treatment.id == 0 
        /* If no rustic treatment is selected */
        ? text("This door needs hinge drilled as a pair. No rustic treatment required.") 
        /* Otherwise, check which rustic treatment is selected */
        : (rustic_treatment.id == 1 
          /* If wire brushing is selected */
          ? text("This door needs hinge drilled as a pair and rustic treatment: wire brushing") 
          : (rustic_treatment.id == 2 
            /* If circle sawn is selected */
            ? text("This door needs hinge drilled as a pair and rustic treatment: circle sawn") 
            : (rustic_treatment.id == 3 
              /* If rough sawn is selected */
              ? text("This door needs hinge drilled as a pair and rustic treatment: rough sawn") 
              /* If circle sawn is selected */
              : text("This door needs hinge drilled as a pair and rustic treatment: circle sawn")))))))

 

Link to comment
Share on other sites

  • Solution

@Joel Bond, wow nice, did the AI-generated formula work?

You can simplify this by several lines if instead of writing unique text each time, you create a column in your rustic treatment attribute, add the text there, and then insert that variable in the text function instead. So then you don't have to write a line for each selection of the attribute, it will just insert whatever text is supposed to go with the option the user selected. (I think you'd still have to write conditions for the 3 different drilling selections though)
image.thumb.png.e94dadd2f7fabb77be7c23f12c17878e.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms and conditions of this site