Creating Components in Cab.rb
-
@frankn said:
I had already tried that and it doesn't work, the only way to get them to show up is to edit the component then the preview shows up. Not a big deal but was just curious if I was doing something wrong with the script/code.
Oh are these YOUR components ?? (ie, NOT Google supplied components,) that your having problems with?
See API: ComponentDefinition.refresh_thumbnail
cdefs = Sketchup.active_model.definitions cdefs.each {|comp| comp.refresh_thumbnail }
-
Also..
-
open the Model Info dialog.
-
Go to the File panel.
-
check the "Redefine thumbnail on save" option
-
-
See API: ComponentDefinition.refresh_thumbnail
cdefs = Sketchup.active_model.definitions cdefs.each {|comp| comp.refresh_thumbnail }
[/quote]
Thanks that worked perfect.
Frank
-
@frankn said:
I've also been looking into adding components to other components and all I found so far is some refernences to subcomponents and parent components but nowhere did I find how those work?
ALL
Sketchup::ComponentDefinition
objects are kept in the model'sSketchup::DefinitionList
collection. ALL of them, regardless of what level any instances (Sketchup::ComponentInstance
,) of them are inserted.
The "level" can at the top (under the model,) or nested many levels deep beneath any combination of Group / ComponentDefinition "parents".The
Entity.parent()
method is inherited (down thruSketchup:Drawingelement
,) to all the objects that can be put into a model.So create all the component definitions you will use, and load them into the model.
To nest a component into another, insert an instance of the subcomponent, into theentities
collection of another component's definition.outer_comp_def.entities.add_instance( inner_comp_def, transform )
.. repeat to suit (ie, you can insert multiple bolt & nut component instances, in another component definition.)
P.S. (a
Group
is a "special" component, and so it also has aSketchup::ComponentDefinition
) -
Hi Dan,
Thanks for the explanation, I think that's what I did without realizing with just trial and error... many, many errors!
I thought you might like to see what I've been working on and by default bothering you with so I included the script.
Keep in mind this is a work in progress and my first attemp at at sort of programming so go easy on me. and please feel free to comment on what I'm doing wrong or that I could improve.
Also the Drawers and Doors functions/inputs aren't implemented yet... still haven't figured that part out.
Thanks again,
Frank
-
I fixed a few things and realized I could call the instances I added to the global component by different names.
It does run slow but I still haven't looked into optimising scripts so hopefully I can speed it up some though I don't mind it though, it's faster then creating a cabinet from scratch.
Next on the to do/ to learn list is...
- Creating door and drawer fronts, creating drawers... shouldn't be a problem.
- Add a user defined number of shelves and insert them evenly spaced in the cabinet... I can do this manually/individually but the math involved in doing them automatically should be fun to figure out!
- Same thing for door and drawer fronts.
- And give a choice of creating an upper or lower cabinet since the building of these is different... I could use 2 different scripts like I did when moding the cab.rb script but I think it would be slick having it all-in-one.
- Add grain direction
- And eventually learning how to export the to a csv file so that I can populate an existing excel spreadsheet that I use... yes I know there are already some cut sheet/list scripts but this is more of a hobby/learning experience and I'd like to see what I can do.
That should be it but I'm already happy with the progress I've made in just 3 or 4 days or learning this stuff.
Again thanks for all the help I really appreciate your teach how to fish approach.
Frank
Advertisement