Display the value of a dynamic component in 2D text

Thanks very much for the explanation Dan! I was close to understanding, I just didn’t notice that the numbers are all stacked, but only one is visible at a time.

You wrote:
“I would myself prefer an observer plugin that removes and replaces text when the DC attribute changes.”

I was wondering the same thing- is there a way to automate the generation of 3D text in code? Your statement seems to imply that you don’t know of any such plugin at this time- is that correct?

Since I’m a newbie, I don’t want to criticize, but the way text is treated seems very limited- in my experience with AutoCAD, attaching text to an object was very simple. And now that I’m having trouble with it, I can see that it’s absolutely essential for me.

As you inferred, my application will required every instance to be unique, which presents another learning challenge- can a new instance of a DC be created as unique automatically?

So I think I can make this method work- I may have to remove alpha characters and encode everything in 0-9 digits, but I will have at least dozens of these DC’s in a drawing, so the processor load may well become untenable.

Yes. Several extension do this.

One is TT’s 3D Text Editor. (The extension actually changes the value of a text attribute in a dictionary belonging to the extension attached to a group object. The 3D text within the group is replaced and regenerated via code using the new attribute value.)
The code is not encrypted.

That specifically gets the text value from a DC dictionary attribute and attaches an observer to watch such a DC component for a particular attribute change … no, I do not yet know of such an extension.

If it is the 2nd or higher instance, then the DC extension code will do the uniquifying automatically.

If you meant via Ruby code, there are API methods to force the uniquifying (which clones the instance’s definition in preparation for changing the definition’s entities collection.)

Yes, well I and many others came from ACAD experience also. However, SketchUp is not CAD, was never designed to be, and never will attempt to be. (It has been billed in the past as “the UNCAD”.)

SketchUp was designed to really be the modelspace only. (It did add rudimentary dimensioning and callouts [referred to as Text objects in the API and GUI,] for simple hobby docs that did not use the Pro edition.)
Paperspace annotation and dimensioning is really meant to be done in the companion LayOut application which comes only with the Pro editions. LayOut has autotext label objects (callouts) which natively can read and reflect changes in Dynamic Attributes of modelspace components. (This does not need any extension. It is a native feature. However authoring Dynamic Components in SketchUp is also a Pro only feature.)

Anyway, back in SketchUp the callouts (actual Text objects with or without leaders) have limited control via the Ruby API. Ie, currently no font size and style control. (The newer “file” C API does have font control but there is yet no parity for the “live” Ruby API.)
We usually get around this (in coding) by creating component files with a variety of settings and loading the file with the desired traits as a component, inserting instances, then exploding the instance and manipulating the object.

The examples you see discussed above are not Text objects per se, … they are groups or instances containing 3D geometry that represents text. Ie, the difference between using the 3D Text tool and the Text (callout) tool.

The benefits of using Text callouts instead are the avoidance of geometric bloat and that the value of the text can be changed without having to destroy and regenerate the objects. (They have a setter method to set or change their value.)

Hi guys. I am glad that the topic is still alive, but it also becomes sad that the problem has not been fully resolved for Sketchup.
Look what happened in the end for me, I just wrote in half of the alphabet (I don’t need to work anymore), everything works. If you sit for a while to suffer, then you can still make non-capital letters.
By the way, the model doesn’t get heavier from hidden letters.
It would be really cool if someone write a good plugin for text and dynamic data interaction.

Thanks again Dan- I know such thorough responses are time consuming.

I understand your point about what SketchUp is and is not, but my sense is that sometimes text objects are really part of an object, like the way 3D text works, but the ability to manipulate that text as text is really important.

I’m a residential builder and I use SketchUp to model designs so that they can be fabricated easily and accurately, and in this specific use case I want to create multiple identical objects each with a unique identifier, thus the need for text manipulation.

Thanks again Dan- I’ll take some time and look closer at the resources you mentioned.

A more specific question-

Dan wrote:
“The benefits of using Text callouts instead are the avoidance of geometric bloat and that the value of the text can be changed without having to destroy and regenerate the objects. (They have a setter method to set or change their value.)”

I think this is a newbie question, but is there a way to ‘drill down’ a text object in a DC, so that it’s position in space relative to the rest of the objects in the DC is fixed and it behaves like a geometric object?

I’m late to this party, but want to mention the existence of a plugin that behaves like a good combination of text and 3D text - the EW plugin FlatText (by Dave Penney).

It comes in a Pro and Free edition, and both now have an API which allows direct access to half a dozen low-poly fonts. More are available for a small charge, and there are instructions for creating your own.

As its name suggests it ‘lies flat’ in whatever plane you place, and remains editable as text.

I’ve incorporated it into an unpublished plugin, to lay out scale numbering for rulers and dials.

You might find it a useful (and inexpensive - $15US) option to explore.

Is your forum profile out of date ? It indicates you are using SketchUp Make 2017 which is not for commercial use and cannot author DCs.

John, the most important question to the text: does he see, for example, LenX and Leni rectangles, can he show them with numbers that change when the object is resized?
Is it possible to write its item “ABССBA” in the component and so that the text displays this value in 2d?

You could consider the instance name as the way of identification, these are reflected in the option and attribute dialogs provided the parents Name attribute is not used and there has been no change in the header. If the DCs are simplified to one level then the label tool will reflect them too. Simplification is, after choices made, by removing all hidden options, exploding all subs with just the parent remaining, note, such instances can be swapped with a file saved definition to reinstate the DC abilities. Although it should be possible manually, some simple ruby scripts can preform the simplification tasks quickly. However all meaningful data needs to be kept in the parent for reports. It really depends how complicated your components are.

ACK! Thanks for pointing that out- I’ll correct it. I upgraded to Pro a while back.

1 Like

Thanks very much pcmoor.

I’m new to DC’s, and I don’t fully follow your suggestion- are you saying that exploding sub components can make the instance name visible on the screen?

I think my components are quite simple- I want to make a graphical symbol (not a realistic representation of any physical object) that has 3-4 ‘text’ fields, one of which would be a unique ID (two characters would be sufficient), which could require but the others would by ‘type’ ID’s that may have multiple instances.

I don’t need much ‘automation’ in what’s in them, I just want to be able easily enter alphanumeric characters and have them be easily changeable if needed.

Hello @kirdudarenko can you please share this model, I am trying to figure it out how to make it to display letter and symbols, but not sure how to make it work. I am not an expert btw. Just need some solution to display text based on dialog box. Thanks