Basic operation on char...
-
Btw, did you create the component? Is it intended for the user to read that reference code?
If not, then you might want to store it in an attribute:Entity#get_attribute: https://developers.google.com/sketchup/docs/ourdoc/entity#get_attribute
Entity#set_attribute: https://developers.google.com/sketchup/docs/ourdoc/entity#set_attribute
classAttributeDictionary: https://developers.google.com/sketchup/docs/ourdoc/attributedictionary
classAttributeDictionaries: https://developers.google.com/sketchup/docs/ourdoc/attributedictionaries -
Yeahhh !! thanks thomthom !!
I searched in french tutorials, that's why I didn't found anything !! lol

-
@thomthom said:
Btw, did you create the component? Is it intended for the user to read that reference code?
If not, then you might want to store it in an attribute:Entity#get_attribute: https://developers.google.com/sketchup/docs/ourdoc/entity#get_attribute
Entity#set_attribute: https://developers.google.com/sketchup/docs/ourdoc/entity#set_attribute
classAttributeDictionary: https://developers.google.com/sketchup/docs/ourdoc/attributedictionary
classAttributeDictionaries: https://developers.google.com/sketchup/docs/ourdoc/attributedictionariesno no ! it's ok !
Components are already create when I put components in design I launch my plug test.
My plugin search all components and then I ask it to display each references include in their description -
@thomthom said:
Btw, did you create the component? Is it intended for the user to read that reference code?
If not, then you might want to store it in an attribute:Entity#get_attribute: https://developers.google.com/sketchup/docs/ourdoc/entity#get_attribute
Entity#set_attribute: https://developers.google.com/sketchup/docs/ourdoc/entity#set_attribute
classAttributeDictionary: https://developers.google.com/sketchup/docs/ourdoc/attributedictionary
classAttributeDictionaries: https://developers.google.com/sketchup/docs/ourdoc/attributedictionariesSorry I don't understand the first time I read your post...
I can use attributes but I see in AUTOMATIC Sketchup.pdf that's attributes cannot be stored when you save a component (I understand that)And put the reference into the description was for me the easiest solution (I hope, if someone has a better solution, tell me).
In that way, I'm sure the reference is shared when I sent a component to my database
-
@njeremy2 said:
Sorry I don't understand the first time I read your post...
I can use attributes but I see in AUTOMATIC Sketchup.pdf that's attributes cannot be stored when you save a component (I understand that)If you store attributes with the definition then you can export the component with the attributes.
Example:
componentinstance.definition.set_attribute('MyTest', 'Foo', 'Bar')Export component
New model
Import exported model
componentinstance.definition.get_attribute('MyTest', 'Foo')
( returns'Bar') -
hmmmm, well...
With that, you can add an attribute called "reference" for all components and set attribute then ?
So if I do like that : componentinstance.definition.set_attribute('Reference', '755480RED', 'Valuedefaultif 755480RED doesnt exist')
That would work ?
And to list all references, how should I do ?
componentinstance.definition.set_attribute('Reference') ? -
Read the API docs again.
set_attributetakes three arguments. The third one is the value.entity.set_attribute( 'DictionaryName', 'Key', 'Value' )
entity.get_attribute( 'DictionaryName', 'Key' )So, if you do something like to to add a reference ID:
entity.set_attribute( 'nJeremy2', 'Reference', referenceID )You can list all definitions with a reference set like so:
<span class="syntaxdefault"><br />for definition in Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">definitions<br /> next if definition</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">image</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault"> next if definition</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">group</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault"> referenceID </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_attribute</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'nJeremy2'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Reference'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> next if referenceID</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Do something to the definition here...<br /></span><span class="syntaxdefault">end<br /></span> -
yeah ok !
I will try but the result is not guarantee -
my solution by putting the reference in description work, it isn't good programming but it works lol
thank you thom !
-
What if your user accidentally modify the description? Or some other plugin the user has install modifies it?
-
@thomthom said:
What if your user accidentally modify the description? Or some other plugin the user has install modifies it?
right...
But I try to use attributes, but I cannot do it right
-
What is not working right?
Do you have a sample code?When assigning an attribute to the definition the attribute is stored whenever you export - it works fine. But if it doesn't work for you then it's probably something in your code that isn't quite right.
-
@thomthom said:
What is not working right?
Do you have a sample code?When assigning an attribute to the definition the attribute is stored whenever you export - it works fine. But if it doesn't work for you then it's probably something in your code that isn't quite right.
I have nothing at home, tomorrow I'll show you what I need to do with that (with screenshots)
-
For this example I put a tree and a Blue cube.
The tree has no description and the Cube has code reference then the real description after "b755480 BLABLABLA".
Then I create a groupe with the 2 objects called "Tree+cube"
Now I export all information with my plugin :

then I export all information in CSV File :

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement