Create a group and manipulate add geom
-
model.definitions.load
will let you import components.
http://code.google.com/apis/sketchup/docs/ourdoc/definitionlist.html#load@skippy1974 said:
- after my creation, I want to put every body un a group and manupilate the group (translation / rotation / scale
I m not able to add some thing or everything in a group
I am not entirely sure what you are trying to do here...
You want to import multiple components into group? - after my creation, I want to put every body un a group and manupilate the group (translation / rotation / scale
-
thx
I created several faces.
I want ti select all and put in a group and after move the group -
All face geometry and intended group must be in the same context ['entities'].
Make an array of the faces ['faces'].
To make a group use...
group=faces[0].parent.entities.add_group(faces)
You can now change thegroup.name
,group.layer
,group.material
etc.
To move the group to a new point...
pt=Geom::Point3d.new(1,2,3)
### or whatever x/y/z is required
tr=Geom::Transformation.new(pt
)
then
group.transform(tr)
The 'group' is now at 'pt'... -
@skippy1974 said:
thx
I created several faces.
I want ti select all and put in a group and after move the groupIf you are creating all the geometry your self, then create the group first, then add the geometry directly into the group. It a different approach than when you model where you create geometry and then group.
-
Thx I will try tomorrow
-
hello,
nothing works
I quite sure, the base of my code is ugly
could you help me to start with somthing well# Name ; Projector 0.9b # Description ; Generic projector drawing # Author ; Sebastien CANAUD # # Usage ; 1. Execute the script # 2. Fill in the GUI # Type ; Script # History; # Beta (25.August.2010) - beta version # First we pull in the standard API hooks. require 'sketchup' # Show the Ruby Console at startup so we can # see any programming errors we may make. Sketchup.send_action "showRubyPanel;" # Add a menu item to launch our plugin. def create_generic_projector # Access the Entities object model = Sketchup.active_model ent = model.entities # Create the input box @projector_choise = "F22" if not @projector_choise projector_choise = ["F12","F22","F32", "LX1500", "CP635"] enums = [projector_choise.join("|")] prompts = ["Projector", "Ratio H", "Ratio V", "lens", "Vertical Shift", "Horizontal Shift ", "Screen height","X", "Y","Z", "Heading", "Pitch", "Roll"] defaults = [@projector_choise,"4", "3", "1.03", "110", "0", "2.2", "0", "0", "0", "0", "0", "0"] results = inputbox prompts, defaults, enums,"Projector Settings" return if not results projector_choise, results[0],results[1], results[2], results[3], results[4], results[5], results[6], results[7], results[8], results[9], results[10], results[11] = results # load projector if( projector_choise == "F12" ) Sketchup.open_file "C;/ANTYCIP/Sketchup components/Projectors/ProjectionDesign_F12.skp" proj = Sketchup.active_model.entities.add_group end if( projector_choise == "F22" ) Sketchup.open_file "C;/ANTYCIP/Sketchup components/Projectors/ProjectionDesign_F22.skp" proj = Sketchup.active_model.entities.add_group end if( projector_choise == "F32" ) Sketchup.open_file "C;/ANTYCIP/Sketchup components/Projectors/ProjectionDesign_F32.skp" proj = Sketchup.active_model.entities.add_group end if( projector_choise == "LX1500" ) Sketchup.open_file "C;/ANTYCIP/Sketchup components/Projectors/ChristieDigital_LX1500.skp" proj = Sketchup.active_model.entities.add_group end if( projector_choise == "CP635" ) Sketchup.open_file "C;/ANTYCIP/Sketchup components/Projectors/Hitachi_CP635.skp" proj = Sketchup.active_model.entities.add_group end # Projector settings ratioH = results[0].to_f ratioV = results[1].to_f lens = results[2].to_f verticalShift = results[3].to_f horizontalShift = results[4].to_f screenHeight = results[5].to_f x = results[9].to_f.mm y = results[10].to_f.mm z = results[11].to_f.mm heading = results[9].to_f.degrees pitch = results[10].to_f.degrees roll = results[11].to_f.degrees # temp norme = ratioH ratioH_in = ratioH.m ratioV_in = ratioV.m new_translationV_in = -verticalShift/2/100.0*ratioV/norme new_translationH_in = -horizontalShift/2/100.0 scale_factor = screenHeight * (ratioH/ratioV) # Create the five points of the pyramid pt1 = [0, 0, 0] pt2 = [lens*ratioH_in/norme, -ratioH_in/2/norme, ratioV_in/2/norme] pt3 = [lens*ratioH_in/norme, ratioH_in/2/norme, ratioV_in/2/norme] pt4 = [lens*ratioH_in/norme, ratioH_in/2/norme, -ratioV_in/2/norme] pt5 = [lens*ratioH_in/norme, -ratioH_in/2/norme, -ratioV_in/2/norme] # Draw the faces ent.add_face(pt1, pt2, pt3) ent.add_face(pt1, pt3, pt4) ent.add_face(pt1, pt4, pt5) ent.add_face(pt1, pt5, pt2) projection_surface = ent.add_face(pt2, pt3, pt4, pt5) # translation for the horizontal and vertical shift tr = Geom;;Transformation.translation [0, new_translationH_in.m, new_translationV_in.m] ent.transform_entities tr, projection_surface # create group group1 = ent.add_group projection_surface.all_connected group1.name = "pyramid" # scale s = Geom;;Transformation.scaling [0, 0, 0], scale_factor, scale_factor, scale_factor ent.transform_entities s, group1 # rotation rh = Geom;;Transformation.rotation [0, 0, 0], [0, 0, 1], heading rp = Geom;;Transformation.rotation [0, 0, 0], [0, 1, 0], pitch rr = Geom;;Transformation.rotation [0, 0, 0], [1, 0, 0], roll ent.transform_entities rh, group1 ent.transform_entities rp, group1 ent.transform_entities rr, group1 # Create the message box #UI.messagebox results[1], MB_MULTILINE, results[0] # printf("screenHeight ;%f",screenHeight) end #-------------------------------------------------------------------------- if( not file_loaded?("projector.rb") ) add_separator_to_menu("Plugins") UI.menu("Plugins").add_item("Generic Projector") { create_generic_projector } end #-------------------------------------------------------------------------- file_loaded("projector.rb")
-
@skippy1974 said:
nothing works
Could you please be more specific? Error messages? Unexpected behaviour? (If so, what is expected?)
-
hello,
As I m a bigginer, I played with the script but I m not sure the based works.the goal is to import a .skp (it's a projector). as I m not able to load I open a new file with the good projector shape.
Sketchup.open_file "C;/Program Files/Google/Google SketchUp 7/Plugins/Projectors/ProjectionDesign_F12.skp"
After that, I create the pyramid of projection using specific parameter.
at the end I would like to move and rotate everthing. But I rotate only the pyramid I would like to merge the 2 group but as the Projector group is not loaded but as open file, I have not the hand on it# create group group1 = ent.add_group projection_surface.all_connected group1.name = "pyramid" # scale s = Geom;;Transformation.scaling [0, 0, 0], scale_factor, scale_factor, scale_factor ent.transform_entities s, group1 # rotation rh = Geom;;Transformation.rotation [0, 0, 0], [0, 0, 1], heading rp = Geom;;Transformation.rotation [0, 0, 0], [0, 1, 0], pitch rr = Geom;;Transformation.rotation [0, 0, 0], [1, 0, 0], roll ent.transform_entities rh, group1 ent.transform_entities rp, group1 ent.transform_entities rr, group1
thanks
-
You are opening the file because you could not load it as a component? Why did you not investigate to why you could not load the component?
hmm....model.definitions.load
did you perhaps assume would insert an instance of the component?model.definitions.load
only loads the .skp into the model - you then have to place it in the model afterwards.model = Sketchup.active_model projector_def = model.definitions.load "C:/Program Files/Google/Google SketchUp 7/Plugins/Projectors/ProjectionDesign_F12.skp" t = Geom::Transformation.new # This will load the component to the origin [0,0,0] projector = model.active_entities.add_instance( projector_def, t )
-
Perfect
I made a stupid mistake
I investigate not
thanks a lot
Advertisement