Insert a component (.skp file) in a precise point of the model space SU

Hello, everyone, a little help, please…
I insert the component (.skp file) into model space, through these few lines of code…

mod = Sketchup.active_model 
ent = mod.entities 
sel = mod.selection 

filepath = File.join(File.dirname(__FILE__),'/Smeg_Elettro/Lavelli/LLR116-2.skp')

cdef = mod.definitions.load(filepath)
mod.place_component(cdef)

I insert this component, through the click of the mouse in the space model…
Sink_1

Sink_2

I would like to insert this component ( .skp file) in a precise point of the model space, through the x, y, z coordinates of a point and that is therefore not hooked to the movement of the mouse… you can… thank you for your help…

https://ruby.sketchup.com/Sketchup/Entities.html#add_instance-instance_method

1 Like

Thank you very much, the advice, where to look to solve my little problem, always very kind in helping…

Okay… I think I understand… thanks again…

model = Sketchup.active_model
entities = model.active_entities

pt = Geom::Point3d.new(15.cm, 25.cm, 40.cm)
transform = Geom::Transformation.new(pt)
  
filepath = File.join(File.dirname(__FILE__),'/Smeg_Elettro/Lavelli/LLR116-2.skp')
defComp = model.definitions
compDef = defComp.load(filepath)
instance = entities.add_instance(compDef, transform)

3 Likes