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

Added show_object as a Method Alias for show #8

Closed
wants to merge 3 commits into from

Conversation

jmwright
Copy link

@jmwright jmwright commented Dec 5, 2019

@bernhard-42 I'm not sure if you'll want to accept this, but I'm working on creating a set of CadQuery tutorials using this extension and MyBinder.org, and I would like to avoid changing the current standard syntax (show_object) as much as possible in the examples.

If you don't want the clutter I understand. I can run the tutorials on my fork.

@bernhard-42
Copy link
Owner

Hi @jmwright
wouldn't
grafik
just do the same?

Or do I miss something?

@bernhard-42
Copy link
Owner

btw. - and you might have seen this - jupyter_cadquery already runs on binder ...

@jmwright
Copy link
Author

jmwright commented Dec 5, 2019

Or do I miss something?

No, I was missing something. That makes more sense than altering the jupyter-cadquery codebase. Thanks.

btw. - and you might have seen this - jupyter_cadquery already runs on binder

Yeah, I've played with it a little bit on MyBinder. Is there a way I can have that open the tutorials? If so, I'm happy to do it that way. I'm not terribly familiar with the way all of the Jupyter infrastructure works.

Here are the tutorials: https://github.com/jmwright/cadquery-contrib/tree/master/tutorials

@bernhard-42
Copy link
Owner

bernhard-42 commented Dec 5, 2019

I admit, I also had a hard time to understand everything ;-)

I guess, what we would need to achieve is independence, i.e. whenever you change something it is reflected on binder without me building a new version of jupyter-cadquery.

One easy way seems to be:

  • Start my binder version of jupyter-cadquery.
  • Open a new notebook
  • add ! git clone https://github.com/jmwright/cadquery-contrib.git <shift-enter>
    And here we go, you can see the newest version of /cadquery-contrib/tutorials/ in jupyter on binder.

I am happy to add a notebook "install cadquery tutorials.ipynb" with this git command to my example folder, so that a new user just has to open this notebook in binder, press <shift-enter>, and get your folder hierarchy in the navigation bar?

@bernhard-42
Copy link
Owner

If we do it like this, it would be great if the python files under examples would actually also be notebooks. Then one could use them the same way on binder like all the other examples, tutorials, ...
Just an idea

@jmwright
Copy link
Author

jmwright commented Dec 5, 2019

Could we point to the upstream repo instead? I've merged my first two tutorials into it: https://github.com/CadQuery/cadquery-contrib

If we do it like this, it would be great if the python files under examples would actually also be notebooks.

So the example files would have both a .py file and an .ipynb file in the examples directory? The contrib repo holding the tutorials only holds advanced examples. There are core examples that are in the main cadquery repo. My tutorials are (or will be) directly based on the core examples, and the full script is at the bottom of the notebook. Ex001 Simple Block is the first one I've completed, and shows what I'm going for. Does that achieve what you're looking for, or do the raw examples in cadquery/examples and cadquery-contrib/examples need to have .ipynb files? If we added those, it would be nice for the notebook to pull the code text from the .py file so that the code only had to be maintained in one place.

@bernhard-42
Copy link
Owner

Could we point to the upstream repo instead

yes sure, the repo path does not matter

grafik

see the cadquery-contrib folder, after git clone and refresh of the navigation bar.

So the example files would have both a .py file and an .ipynb file in the examples directory?

Here is the issue with *.py files:
grafik

You can actually read them but not run them. If that is sufficient for you, all fine ;-)
I just put myself into the shoes of a user who might want to execute the code and see the result. On the other side, the user can just mark all lines in the py file, open an empty notebook and paste it and can run it. Not much of a deal ...

So this is not about what I would like to see, but more about how you'd like to have the experience for the end user. Should everything be runnable in notebook or not (and both might be ok).

I guess, I would only add the "install cadquery tutorials.ipynb" notebook to my repo if you want - and I am happy to take over what you would like to have additionally in this notebook. And then leave the content, format and experience of the examples and tutorials with you, the maintainers of the cadquery-contrib repo.

@bernhard-42
Copy link
Owner

And btw., if you would prefer complete independence of our two projects, instead of me adding a "install contrib" notebook you could have a section in your readme with an explanation

  • Click on the binder link for jupyter-cadquery
  • Open a new notebook
  • Add !git clone ... into a cell and press <shift-enter>
  • Press "refresh" on the navigation bar.

@bernhard-42
Copy link
Owner

Side note: 3D_Printer_Extrusion_Support.py copied into a notebook throws an exception for me

IndexError                                Traceback (most recent call last)
<ipython-input-1-5f4eaaefbfe8> in <module>
    141 # add reinforcement holes
    142 cutout_rad -= 2*cutout_offset
--> 143 res = res.faces('>Z').workplane().\
    144           pushPoints([(-cutout_rad, -main_plate_thickness/4),
    145                       (cutout_rad, -main_plate_thickness/4)]).\
...
IndexError: list index out of range

@jmwright
Copy link
Author

jmwright commented Dec 5, 2019

if you would prefer complete independence of our two projects, instead of me adding a "install contrib" notebook you could have a section in your readme with an explanation

I'd like to leverage your great work as much as possible. My end goal was to try to enable users to get to the tutorials by simply clicking a link in the cadquery readme. Most CadQuery users are used to development workflows though, and so executing the git clone step shouldn't be a problem for them. If you would create a install cadquery tutorials.ipynb notebook, that would be great. Once everything is in place I'll add instructions to the CadQuery docs.

Is there some way to make the raw .py examples and the .ipynb files work seamlessly together with something like the %load directive? https://stackoverflow.com/questions/21034373/how-to-load-edit-run-save-text-files-py-into-an-ipython-notebook-cell

Side note: 3D_Printer_Extrusion_Support.py copied into a notebook throws an exception for me

That example throws the same error in CQ-editor as well. It must have gotten broken during the transition to PythonOCC and was never noticed because it was in the contrib repo. I've created an issue for it: CadQuery/cadquery-contrib#3

And then leave the content, format and experience of the examples and tutorials with you, the maintainers of the cadquery-contrib repo.

We don't advertise the contrib repo much, but it's a place where the community can contribute things like examples, tutorials and helpful scripts. I think the end goal would be for the broader community to be the maintainers of it, but for the time being it's just the core devs. We welcome contributions of course though.

@jmwright
Copy link
Author

jmwright commented Dec 6, 2019

@bernhard-42 I'm going to go ahead and close this PR since it's no longer relevant (but was useful for sparking a good discussion).

@jmwright jmwright closed this Dec 6, 2019
@bernhard-42
Copy link
Owner

@jmwright I have created a notebook https://github.com/bernhard-42/jupyter-cadquery/blob/master/examples/install-cadquery-contrib.ipynb which allows to clone cadquery-contrib

Does this help?

@jmwright
Copy link
Author

jmwright commented Dec 7, 2019

Does this help?

Yes it does, thank you. I was able to remove a couple of clunky bullet points from the instructions. I've updated the cadquery-contrib/tutorials readme to reflect the changes.

@bernhard-42
Copy link
Owner

great.
I just gave it a try on my iPad to see whether jupyter-cadquery works on this device and it does. Even the size of the cad view is fine. Nice, I wasn't aware of this 😀

@jmwright
Copy link
Author

jmwright commented Dec 7, 2019

I just gave it a try on my iPad to see whether jupyter-cadquery works on this device and it does.

That's great. Out of curiosity I tried the tutorial on an Android tablet (Chrome browser). The viewer loaded fine, but the model never displayed. I don't have access to the developer tools or I would dig deeper.

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

Successfully merging this pull request may close these issues.

2 participants