Add model at runtime and take user input

Hi All,
I am new to sketchup.
I am creating a plugin which takes the height of a person that can walk inside the model say house.
Whenever a user want to change height he is shown a 3d model of human which can be scaled.
Like this :
My question is how can I add a 3d model of human, take the input from user and remove the 3d model of human once user is done with setting.

I was able to find adding the 3d model of human using

          cdef = model.definitions.load("skp/test.skp")
          return unless cdef

          point =, 0, 0)
          cinst = model.active_entities.add_instance(cdef,

But i am not able to give the correct path to load method.
here is the directory structure

Can you elaborate on why are you not able to give the correct path?
In the example you use a relative file path to load the component. If the image of your folder structure is the files in your extension then you need to resolve the path relative to where your extension is:

If your code is located in sentioloader.rb then you can resolve the path like this:

extension_path = File.expand(File.join(__dir__, '..'))
skp_path = File.join(extension_path , 'skp')
skp_file = File.join(skp_path, 'test.skp')

Replaced expand with expand_path.
It is working.
Could you help me out with other things ?

You can also simply do this:

path = File::join( File::dirname(__dir__), 'skp', 'test.skp' )

… OR …

path = File::expand_path( '../skp/test.skp', __dir__ )

… and afterward do …

cdef = model.definitions.load( path )


Search the Ruby API sub-category first, and if you do not find your question,
then post your questions there in the Ruby API sub-category, one topic for each question.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.