Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an API #47

Open
thomthom opened this issue Nov 21, 2012 · 7 comments
Open

Implement an API #47

thomthom opened this issue Nov 21, 2012 · 7 comments

Comments

@thomthom
Copy link
Member

Discussions around other issues show that we need an API to the importer and exporter. An API will have multiple purposes:

  • Import/Export can be unit tested.
  • Import/Export can be profiled - checked for performance.
  • Can be called externally without the UI

Any thoughts on the design?

@thomthom
Copy link
Member Author

Reference Issue: #26

(There's at least another - but I cannot find it right now.)

@scottlininger
Copy link
Contributor

First step is to refactor so any UI calls are decoupled from the actual work of importing or exporting. Then start writing unit tests of each method, using optional dependency injection in the constructor to make the tests run instantly and without user interaction.

For example, instead of calling UI.foo inside our code, we'd inject at constructor time a ui_module param, then all internal calls do through @ui_module.foo. If nothing is passed in, it defaults to the usual UI bit. Then you can write your own UI module inside your unit test where UI.messagebox does something predictable.

As for the design of the import/export API itself, I'd need to think about it. Is import always done directly into the model? Should it create and return a new group? Lots of ways...

@scottlininger
Copy link
Contributor

Would it be possible to extend Model.export to understand .stl inherently? That might be the best export API.

@jimfoltz
Copy link
Contributor

Would it be possible to extend Model.export to understand .stl inherently?

Wouldn't that need done on the C++ side? On second thought, could it be done using Ruby by aliasing the export method?

@jimfoltz
Copy link
Contributor

Is import always done directly into the model? Should it create and return a new group?

The way I wrote it is if there is already >0 entities in the model, then a new group is used so as not to interfere. If not, then geometry is added to the model. I think I based it on how the dxf importer worked.

@ChrisFullmer
Copy link
Member

Yeah, that is how dwgs import.

On Wed, Nov 21, 2012 at 4:50 PM, Jim Foltz notifications@github.com wrote:

Is import always done directly into the model? Should it create and return
a new group?

The way I wrote it is if there is already >0 entities in the model, then a
new group is used so as not to interfere. If not, then geometry is added to
the model. I think I based it on how the dxf importer worked.


Reply to this email directly or view it on GitHubhttps://github.com//issues/47#issuecomment-10620284.

@thomthom
Copy link
Member Author

Wouldn't that need done on the C++ side? On second thought, could it be done using Ruby by aliasing the export method?
You can alias it yes. But what worries me is, what if other exporters do the same. How can they be chained so they do not cause conflicts?

I think I'd prefer if the Ruby API was modified on the SketchUp side of things so that Model.export would query registered sets of Exporters if they can handle the filetype. (Provided we get an Exporter class, similar to Importer.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants