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

Add some examples with substance. #20

Open
DanRathbun opened this issue Oct 1, 2020 · 7 comments
Open

Add some examples with substance. #20

DanRathbun opened this issue Oct 1, 2020 · 7 comments

Comments

@DanRathbun
Copy link

DanRathbun commented Oct 1, 2020

The Hello World is a silly and meaningless example.

Add some examples with substance. Something that at least looks up some SketchUp model properties and displays them.

@thomthom
Copy link
Member

thomthom commented Oct 5, 2020

Got a Ruby equivalent for what you are looking for?

The Hello World is a silly and meaningless example.

The main purpose of this example has been to provide the headers and lib along with project setup to compile a Ruby C extension that runs within SketchUp. For that it has served well.

I can see that there are opportunities to do more with the examples. (However, just because it isn't 100% what you expect doesn't mean it isn't useful for others. And there any many ways to suggests improvements in more positive constructive language.)

Also, Pull Requests are welcome 😉!

@DanRathbun
Copy link
Author

Observation: Your adding of an inner loop is the kind of thing that makes a good example ...

https://forums.sketchup.com/t/how-to-create-a-hole-using-the-inner-loop/74239/3

... but is probably more suited to the Live-C example repo: https://github.com/SketchUp/sketchup-live-c-api
applying to a external file.

@thomthom
Copy link
Member

Are you looking for examples on how to use Ruby's C API? How to make method calls to Ruby from C?

@DanRathbun
Copy link
Author

Not specifically. This topic is about "examples with substance" ...
So any examples showing basics of using the C API in standalone or "live" mode are "good".

But specific to your question, I've often posted links to the companion book for "Writing Ruby Extensions in C". It is informative although quite old now. (It was written when Ruby 1.9 was current.)
It can be overwhelming if a coder is just looking for the simply how to call SketchUp's Ruby API methods from a C extension. So I would have to answer yes, that a simple example could be beneficial. (I think you have already posted such an example either in the forums, or in some of the tracker issue threads.)

@thomthom
Copy link
Member

The main purpose of this example repo is setting up the project, along with providing the headers and libs. My experience with Ruby C extensions was that writing the code was the easy part, but getting a project setup to compile and link was the hard part.

My go-to reference for the Ruby C API is this one: https://silverhammermba.github.io/emberb/c/

@DanRathbun
Copy link
Author

Okay this is nice ... BUT ... your taking this discussion off-topic.

Again, this is about examples of using the SketchUp C API. Showing tasks that are NOT obvious to new users of the C API and probably know little of how SketchUp works. (Ie, they need to write an importer for a 3rd party application, etc.)

For example, ... the question you answered today about copying text objects from model to model. There is no explanation that an exception will occur if a text object's font is not set.

There are other tasks also using the SU C API where the order that things are done must be correct.

@thomthom
Copy link
Member

I'd say such examples fit better in pure C API examples. They are not tied to Ruby C extension or live C API. (I fully agree that we need better C API examples.)

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

No branches or pull requests

2 participants