Bigger bounding box of loaded model

Hi All,
I am adding a model with Ruby apis as following

        model = Sketchup.active_model
        scalar_path = File.expand_path(File.join(__dir__, '../skp/SentioMan.skp'))
        human_definition = model.definitions.load(scalar_path)
        return unless human_definition

        #Adding at the max bounds of current model
        @human_point = Sketchup.active_model.bounds.max
        @human_component = model.active_entities.add_instance(human_definition, Geom::Transformation.new(@human_point))

This is how actual model looks like

And with some already active model

As you can see after loading the man the bounding box of man has increased.
How can I rectify this?

The bounding box in the first image is not the bounding box of the model itself but the bounding box of a group/component withing the model. There can very well be entities outside of that group/component, making the model bb bigger. You can use the Ruby API to check for additional entities.

1 Like

I agree you probably have hidden content in your component…

I would also be cautious of bounds.max

  #Adding at the max bounds of current model
  @human_point = Sketchup.active_model.bounds.max
  # on a mac #max.to_a returns [-1.0e+30, 1.0e+30, 1.0e+30] for an new model...   
  @human_point = ORIGIN if Sketchup.active_model.entities.to_a.empty?
  # unless you want them in the 'air' I would pin them to the ground or other plane...
   tr = Geom::Transformation.new([0, @human_point[1], 0])
   @human_component = model.active_entities.add_instance(human_definition,tr)

john

1 Like

@rajawat

You forum profile does not indicate what SketchUp version you are developing on.

When you report errors, it helps for us to know what SketchUp version and if you have issues with specific components or models, then post the component and/or model files with the error report.

1 Like

Thank you guys. There was indeed a problem in model being added.
@DanRathbun I will update my profile.

1 Like

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