edit_transform not available in the C-API?

edit_transform not available in the C-API?

Postby pixelcruncher » Tue Sep 05, 2023 11:52 am

Hey folks,

SketchUp offers the edit_transform instance model for the model: https://ruby.sketchup.com/Sketchup/Model.html#edit_transform-instance_method - However, it seems that there's no equivalent in the C-API. I checked the documentation of the SUModelRef: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html.

Am I not looking in the right place, or is there an alternative way to get the edit_transform?

Cheers,
Thomas
0
I am the creator of Rayscaper, an interactive, photorealistic render engine for SketchUp that is fun to use.
User avatar
pixelcruncher 
Premium Member
Premium Member
 

Re: edit_transform not available in the C-API?

Postby Dan Rathbun » Sun Feb 25, 2024 1:40 am

The C API is mainly written to act upon files.
There is only some limited things you can do with "live" models.
Currently, the C API cannot be used to modify the active model.



You can get the active edit path via: SUModelGetActivePath()
... and from it the transform via: SUInstancePathGetTransform()
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: edit_transform not available in the C-API?

    Postby pixelcruncher » Sun Feb 25, 2024 6:49 am

    Dan Rathbun wrote:The C API is mainly written to act upon files.
    There is only some limited things you can do with "live" models.
    Currently, the C API cannot be used to modify the active model.



    You can get the active edit path via: SUModelGetActivePath()
    ... and from it the transform via: SUInstancePathGetTransform()


    Thanks, Dan, for the information! I solved it in my code by having a ModelObserver, implementing onActivePathChanged, and passing it to my C-extension code.

    Even though you cannot modify the active model, you still need to know the edit transformation for some cases. If a user opens a model to edit, if you query the instance transformation, it will be a world-coordinate transformation instead of a transformation relative to the parent. My C code assumes transformations relative to the parent, so I must calculate that using the edit transformation. You probably already knew this, but I'm putting it here for posterity.

    Cheers,
    Thomas
    0
    I am the creator of Rayscaper, an interactive, photorealistic render engine for SketchUp that is fun to use.
    User avatar
    pixelcruncher 
    Premium Member
    Premium Member
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 9 guests