Newbie's anxiety ---- simple question
-
Help!
I wanna use "bed" in "Components Sampler", get its attribute"LenZ" , than write it into a txt file.
How to write the codes?I watched a book named "Automatic Sketchup Creating 3D Models in Ruby",still do nothing

anyone help?Thanks -
Not all things have attributes.
LenZ is one that a Dynamic Component has.
I think that 'bed' isn't a DC ?
If you want the size of something use something like bb=entity.bounds
and then z=bb.depth
x id width and y is height for a bounding box...
If you explain what you wanted this for it might help.
Writing a value to a text file is not much use ?
The book you refer to has lots of help parts about all of this and more...
Don't run before you can walk...
-
thanks a lot:)
my real obstacle is : I create a component in design mode, its name : cup.
when i write the code : bb=cup.bound , error coming:(bb=cup.bounds
Error: #<NameError: undefined local variable or method `cup' for main:Object>
(eval)Is my component"cup" not a entity?
I hope you can give me the fully code segment about how to use defined componet"cup".thanks a lot!!!!!

-
Ahhh...
If you have definitely made a component called 'cup' [or even imported one into your SKP] then it should show up in the Component Browser > Model [small-house] icon...
You need to make a reference to the definition thus
model=Sketchup.active_model defs=model.definitions cup=defs["cup"]
IF there is component called 'cup' you now have a 'reference' called 'cup' that points to it.
If you type
cup
you should get a reference to it.
Then
bb=cup.bounds x=bb.depth
etc ...
If you have more questions [I'm sure you will!] post them in the Ruby forums - like the Developers' Section...
-
It really done:)
thanks a lot .
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