Hi all. I have credited a dynamic component that allows me to enter a product length, and it creates the product using length and copy. I am now trying to change the material (colour) based on the length, but I am getting glitches on certain lengths.
The product is a tubular aluminium “truss beam”, and they can be bolted together to form for complex systems for exhibition stands, etc.
In real life the product length can be anything from 250mm to 4000mm.
When I draw the systems, I’d like it to automatically colour the individual truss beams, for ID’ing for whoever is building the system.
It is basically working; however there are certain standard lengths which fail, ie the colour reverts to the default, instead of the colour detailed in the material formula. The lengths it fails on are (all mm) - 3500, 3250, 2750, 2250, 1750, 250. It works for 4000, 3750, 3000, 2500, 2000, 1500, 1250, 1000, 750, 500.
I suspect it is something to do with sketchup working
Dynamic colouring.skp (228.6 KB)
in inches, whereas our product is in mm. Can anybody shed some light on it ? Many thanks
Not sure why this should make a difference but it seems to work if you change the attributes of the LenZ in the parent component from Display in “End user’s model units” to Display in “Centimetres”.
Then, entering 350 cm in the prompt box works correctly and the beam is coloured “olive”.
Here it is with that change made:
ST UNIT_2-edited.skp (150.7 KB)
But setting that box to “End user’s model units” or “Millimetres” and it breaks it as before (some of your preset measurement work correctly, others do not).
I’ve no idea why. It is very strange as the other measurements work as you had the Dynamic Component set up (with Display in “End user’s model units” chosen as the option).
Is the “Show unit format” box enabled in your Model Info>Units dialog. There is a bug in Dynamic Components from ever since they were relesed that switches the metric units to inches if the box is unchecked.
Sure you uploaded the right file, because I see no complete DC and with none Component options; just separated components.
Yes. I just double-checked by downloading the file I uploaded and it opens fine as a Dynamic Component.
Note that when you download a Dynamic Component .skp file you need to open it by either dragging the downloaded file into an open Sketchup document, or putting it with your other Dynamic Components and opening it using the Component Window. If you simply double-click the downloaded .skp file it will open as a Sketchup model and will not work as a Dynamic Component.
So this will work:
But simply opening the file will not work. It will open the file as a model without the dynamic attributes.
Yes, you’r right, I was just sleeping ( almost literally ) .
Thanks so much for that. Good enough ! I think I tried everything else - including mm / users units, but didn’t think of cm !
I did want to take it further and create a formula that gave the colour as a numerical code, (we do go down to the millimetre in manufacturing), but this works for 99% of applications, and leaves the in-betweens the default colour for manually identifying.
Really appreciate you looking at it.
Hi there - thanks for your suggestion. I tried that but it came up with the same issue. For now - as above - it was resolved by using “centimeters” in the Display Units of the Component Attributes.
Really appreciate your idea though.
I had another thought about this. Your test is getting its number directly from the main component’s LenZ (which is displaying a measurement like “350 cm”) but your test is testing for just numbers like “350”. Maybe this is what is confusing it in some cases.
So, leaving the Dynamic Component as “cm” as its unit of measurement, I made a custom attribute called “Control” that copies LenZ but this custom attribute is set to text rather than any unit of measurement.
When your test references this “Control” attribute instead of “LenZ” it seems to work fine and you can leave the display of units as millimetres.
Here it is again, using this method:
ST UNIT_2-edited v2.skp (150.1 KB)
Material
=choose(ceiling(lenx/25),“silver”,“orange”,“cyan”,“red”,“lime”,“purple”,“green”,“lime”,“blue”,“olive”,“magenta”,“Blue”,“SteelBlue”,“Olive”,“MediumSpringGreen”,“Yellow”)
Excellent ! I hate working in cm. Works great, thanks !
Thanks pcmoor - much neater, and gets me to use a function I’ve never thought of ! In this case I might prefer it so that the non-colour of in-between lengths highlights the further attention, but I’m sure that’s just a tweak away.
Really appreciate it.
=If (lenz-int(lenz), “silver”,choose(ceiling(lenz/25),“silver”,“orange”,“cyan”,“red”,“lime”,“purple”,“green”,“lime”,“blue”,“olive”,“magenta”,“Blue”,“SteelBlue”,“Olive”,“MediumSpringGreen”,“Yellow”))
if condition to see remainder (in-between) shows “silver” or color of choice
As false value has to be integer, no need for ceiling function
=If (lenz-int(lenz), “silver”,choose((lenz/25,“silver”,“orange”,“cyan”,“red”,“lime”,“purple”,“green”,“lime”,“blue”,“olive”,“magenta”,“Blue”,“SteelBlue”,“Olive”,“MediumSpringGreen”,“Yellow”))
You could automate lenz so only the fixed lengths can be chosen, using the “current” formula. then the other formula would be simplified or redundant
=ceiling(current(“lenz”)*2.54/25)*25
where lenz is read only, but changed with scale tool