Display the value of a dynamic component in 2D text

My name is Kirill (from Kyiv), sorry for my English, if something is not clear.
I have a difficult task with 2D text and no one can help, maybe you will succeed. In short - you need to output 2D text from Component Options to the drawing.
For example, I have a rectangle area of ​​6m2 (calculated automatically) and I need this value to be in the lower right corner.
I also have a number that I assign manually and I need it to be displayed in the upper left corner.
The flat text, which many people use, has nothing to do with the attributes of the component, and I need to display this data through a generated report.


I have a template that I am working with, passing in an attachment as an example.
At this stage, when I do large projects, I enter the text manually and I can make a mistake with the number or area, I would like to avoid them by automating them. Many thanks.

I guess unfortunately you can’t add a 2d text from dynamic component attributes. Other than using the attribute access of labels in layout (which I never used personally)

I do not have so much experience or practice, but a long time ago I did a little study, you might can use it:
https://forums.sketchup.com/t/dynamic-label-concept-numbers-only/94727?u=dezmo

1 Like

You will need a companion plugin to “read” the target dynamic attributes and add 3D text groups to the dynamic component. Doing so will mean that each one of your dynamic component instances is unique because the added text objects would be the same for ALL instances.

(This means that each instance getting the text will need it’s own unique definition.)

Thanks for the fact that the text appears depending on the size of the object, this is already the right way, I will try to understand more in your file.

1 Like

Yes, absolutely right, you just need to figure out how to do it. I think with some kind of formula you need to display values from attributes in a 2D external view

There is another possibility that I became aware of while using Dave Penny’s Flat Text plugin (from Extension Warehouse) to draw flat text for me inside my own plugin (not yet published).

That has a Ruby API which you might be able to combine into your DC. It’s available only in the Pro version of Flat Text. It isn’t expensive (~$15) and there’s a free trial for a week or two.

I’m not a skilled Ruby programmer, and have only a limited experience of creating DCs.

But I think I have read that it is possible to combine Ruby and a DC, which after all is only itself based on a Ruby extension.

But it’s beyond my experience to know how to do it.

Yes, I just talked with Dave Penny, he suggested me to write to the forum.

Dezmo, thanks to your file, my colleague and I used the hide / unhide system and, as a result, implemented one field with writing letters and symbols, and the second automatically calculates the area of a rectangle.
When scaling an object, all numbers do not change their dimensions and place. Only 2 points did not win: “0” is not displayed, the formula considers that it is not. Replaced with “O”. And the sign “-” also does not want to be determined - it was replaced by “_”.

Please post any issues you think are bugs or those that need improvement to topic:

it is not an error but rather the wrong formula to use,

value(0)=0, value(.)=0, value(-}=0, value(a)=0…

use the find() instead, note you add the value times by the number of digits to search to the end to avoid the error then compare the result with the string length.
The example is for 0, 1, 2, and point, the 0 is a special example whereas the others can be copied. made unique and changed to make the other digits, a task that can be done by you, changing the header of the new component to an appropriate name, and inserting the digital value in the “lookup” attribute.
find and copy.skp (92.2 KB)

1 Like

You could alter dezmo concept to allow for use of decimal points and other symbols, letters by removing the “value” function, then for cases that naturally evaluate like the decimal point, use the find method.
Kind of make use of both concepts

Capture

label with dot.skp (630.4 KB)

1 Like

Super, thanks for the tip, find () is really more suitable for this task. See what I got thanks to you!)
PS: The only thing is that I can’t enter the number “1.” when dot is at the end it is not shown, but “1.1” works all 3 characters. You also can’t start with the number “01”

The problem is in passing the input as text and stopping it from being evaluated, the concatenate formula to add the strings helps, so if we put a wrapper around the input

concatenate("(",input,")") then allow for the bracket in our results?

if using “same as the label with dot” version of dezmo solution (which is in essence the solution you are using then please give him the solution tick)

first check that text is the input:-

Now use the Bracket delimiters or some of your own to protect the text

Then you need to change the results to suit, or you may even like the wrapper delimiters to be part of your project

Cheers and good to see the progress you are making

3 Likes

Thank you, this option with brackets () gives the correct display of the entered text. But there is a minus, these brackets appeared in the text field, but they are not visible (since I have not drawn this element). In general, I can solve the alignment problem by moving the position itself, but not very technically, because if there were parentheses, they would be displayed.

I don’t mind, because my good part of knowledge is based on your “old” posts in the fórum… :wink:

2 Likes

You can decrease the number of digits copied by 2, then limit the scope using MID again

neater:

I do not know how you do it and where did you get such good knowledge, but it worked! Brilliant, thanks!))

Hoping for some clarification- my application is much simpler- I just want to enter a value in the Options dialog and have it change the 3D text. I’ve spent quite a bit of time disassembling and looking at the dezmo example, and I can see where the value is stored, and I can manipulate it in the ‘Attributes’ dialog, but I can’t see how the value is ‘connected’ to the 3D text- how the value of the 3D text is set by a value in the attributes of the DC. From other examples, it seems 3D text is just geometry, so it seems this shouldn’t be possible, and yet the 3D text is changing.

Thanks in advance for any guidance or clarification.

It (dezmo’s example) doesn’t actually change a 3D text field.

It uses the hidden DC attribute to hide all characters except the character (or number) for that particular digit. So each digit is a copy subcomponent which has within it as children, ALL of the possible characters that might need to be displayed for each digit (or “place”) in the text. This would be numbers and decimal point, perhaps a minus sign, etc. If you wanted letters then the digit/place subcomponent would need 26 or so more character subcomponents.

So the formula determines for each “place” which one of the numerous character subcomponents will be the visible one and the rest will be set hidden.

The draw back is that 3D text (even that which appears as flat 2D text) is intricate geometry which might bloat the model using this approach where most character subcomponent instances are part of the entities but hidden.


I would myself prefer an observer plugin that removes and replaces text when the DC attribute changes.

This would likely mean that each DC instance that needed unique text labels would require a unique component definition.

Probably not a drawback as the copy feature of DCs also creates unique definitions having unique entities collections.

1 Like