Creating components from existing objects
-
Are your script also generating the geometry you want to place in the component? If so, then you should just add it directly to the component definition.
-
This seems to work.
mod = Sketchup.active_model ent = mod.entities sel = mod.selection wgrp=ent.add_group ent.to_a #create a group containing all existing entities wcmp=wgrp.to_component #convert the group to a component/instance. wcmp.definition.name="World" #give it a name
-
@thomthom said:
Are your script also generating the geometry you want to place in the component? If so, then you should just add it directly to the component definition.
Hi Tom,
The geometries are generated by the users as they go along. I'm trying to make this a tool so as and when the user switches to the tool, all of the currently existing models (except certain objects) become part of the miniature view
-
@sdmitch said:
This seems to work.
mod = Sketchup.active_model > ent = mod.entities > sel = mod.selection > > wgrp=ent.add_group ent.to_a #create a group containing all existing entities > wcmp=wgrp.to_component #convert the group to a component/instance. > wcmp.definition.name="World" #give it a name >
Ahhh! group to component! Thank you so much
-
Another question on a related note.
Is there a way to set the Level Of Detail on the miniature component instance alone?
It seems to be affecting performance with large models like castles and for the size at which I'm rendering the miniature, I couldn't care if its quality went down -
There is always a way but at what cost. The code would no doubt expand from 3 lines to 3000.
-
Beware... if
ents
ismodel.entities
and that's not the current 'active_entities' context thenents.add_group(ents.to_a)
orents.add_group(model.selection.to_a)
etc will Bugsplat!So... always ensure that the
ents=model.**active_**entities
and the objects you are trying to add to the new group are in the same context - hence the recommendation for 'selection' because the user can't manually select things that are not in the current active context... -
@tig said:
Beware... if
ents
ismodel.entities
and that's not the current 'active_entities' context thenents.add_group(ents.to_a)
orents.add_group(model.selection.to_a)
etc will Bugsplat!So... always ensure that the
ents=model.**active_**entities
and the objects you are trying to add to the new group are in the same context - hence the recommendation for 'selection' because the user can't manually select things that are not in the current active context...TIG thanks. Will keep that in mind
-
You might play with the Fog settings. Adjust the near and far clipping planes. (But this is really not LOD.)
-
@dan rathbun said:
You might play with the Fog settings. Adjust the near and far clipping planes. (But this is really not LOD.)
Thanks Dan. Will give that a try
-
@sdmitch said:
There is always a way but at what cost. The code would no doubt expand from 3 lines to 3000.
I'm on a framerate sensitive medium, so anything I can do to improve frame rate would be useful. It would be great if you have any tips on how to set the LOD for the miniature.
Advertisement