SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Create embedded viewports directly from SketchUp geometry #479

Open Eneroth3 opened 4 years ago

Eneroth3 commented 4 years ago

LayOut has a quite interesting feature - the ability to copy content of a SketchUp model through the clipboard, and have it become an embedded model in the LayOut document, with no connection to SketchUp or external files. In a manual LO workflow this isn't super useful, as what you do with LayOut really is to set up a pipeline from 3d model to presentation that allows for later changes to the model.

When using the API on the other hand and creating an automated pipeline, this ability would be highly useful. In combination with the ability to set camera positions directly to viewports, with no dummy scenes, this could be used to generate drawings of individual objects in a model with no dummy model files needed.

If you want to make an extension today that generates drawings for say the selected component, e.g. triggered from its context menu, you'd have to save out that component to a dummy file, potentially overriding any link to an external file the user has set up, or save it out to the file it is already associated with, potentially overriding a file the user doesn't want changed. It's messy, and something more akin to the copy paste approach of the GUI would be welcome.

Something like an overload to the Layout::SketchUpModel constructor that takes a Sketchup::ComponentDefinition as parameter could maybe be used for this. Or even just as array of drawingelements?

Now that we can export PDFs from the LayOut API, and the LO API is constantly growing with more properties you previously only could control from the API, I think a way to copy/embed specific geometry is the last big step to set up our own SketchUp to presentation pipelines.

thomthom commented 4 years ago

Ping! @ackarkka - for consideration.

Eneroth3 commented 3 years ago

This could be achieved with #480 along with a viewport unlink method. That would probably be a lot cleaner and simpler way to achieve the same end result.

thomthom commented 3 years ago

Yes? Should we add extra documentation and examples perhaps if #480 could solve this scenario?

DanRathbun commented 3 years ago

Just getting my thinking straight ...

@Eneroth3 : _Something like an overload to the Layout::SketchUpModel constructor that takes a Sketchup::ComponentDefinition as parameter could maybe be used for this._

That would be probably the best thing to do, rather than invent an #import_definition method (or similar that coders would not be looking for.) If used in an older version of SketchUp, a normal Ruby TypeError would be raised as the constructor would be expecting a String argument.

But ... keep in mind that in a SketchUp model, the items from collections (that the definition uses, excepting it's own entities,) are not yet embedded within the definition object. This means that the owning model object must still be available until the LayOut viewport is fully instantiated. The procedure must collect used collection items (ie ... subcomponent / group definitions, and all used materials, textures, layers, scenes, styles, classifications, etc.)

This means that the functionality of the SketchUp definition save routine (except for the actual disk write) would be needed to build what LayOut considers it's embedded SKP model.

To that end the LO C API would need something like:

LO_RESULT LOSketchUpModelCreateFromDefinition(
    LOSketchUpModelRef *model, SUComponentDefinitionRef *compdef, const LOAxisAlignedRect2D *bounds);

The function could do the cast to SUEntityRef and retrieve the SUModelRef to access the needed collections.

Also since the omission of a path property for the LO Viewport is being discussed, the following feature is related: Issue #324: Layout::SketchUpModel#path and #path= methods missing

Eneroth3 commented 3 years ago

So, I fail to understand how Definition#save_copy #480 is going to prevent LayOut from making the file association

That's where the proposed LayOut viewport unlink method comes in.

DanRathbun commented 3 years ago

What proposed unlink method ? Is there an LO issue open for this ?

How can there be a workaround to publish when neither the SU nor LO method yet exists ?


You laid out this feature request as ...

LayOut has a quite interesting feature - the ability to copy content of a SketchUp model through the clipboard, and have it become an embedded model in the LayOut document, with no connection to SketchUp or external files. ... When using the API on the other hand and creating an automated pipeline, this ability would be highly useful.

... and titled it ...

Create embedded viewports directly from SketchUp geometry

So, I will disagree that directly embedded SketchUp geometry can be solved using the so called "dummy" file export, make LO viewport, then unlink workflow. It's a hack.

It will take authoring 2 methods in the Ruby API rather than modifying 1 Ruby constructor to leverage code that should already exist.