Hi all, I decided to make a minimal example of the Part Attachment feature for custom scripted objects to learn it better myself.
Also, it seemed other were struggling with this. For example, here.
See the following repository for detail:
https://github.com/gbroques/freecad-par ... on-example
Hopefully this helps others who are interested in making their custom scripted objects "attachable" to other objects in FreeCAD.
Let me know if you have any thoughts or feedback!
Part Attachment Feature with Custom Scripted Objects
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Part Attachment Feature with Custom Scripted Objects
Last edited by gbroques on Tue May 05, 2020 3:33 am, edited 1 time in total.
Re: Part Attachment Feature with Custom Scripted Objects
I suggest you don't name it .FCMacro because that doesn't allow editors to recognize it immediately as a Python file. It's just a Python file, so add the .py extension. Then it could be imported and run at the same time.gbroques wrote: ↑Tue May 05, 2020 2:21 am ...
See the following repository for detail:
https://github.com/gbroques/freecad-par ... on-example
...
Also, maybe you'd be interested in adding it to the wiki, for example, to some document called, Scripted objects with attachment, or something similar. And that example could be placed somewhere in the Power users hub.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Part Attachment Feature with Custom Scripted Objects
Good point. I renamed the extension to .py in the GitHub repository for syntax highlighting purposes.
---
Great idea! I added this to the Wiki and included a link to it on the Power users hub:vocx wrote: ↑Tue May 05, 2020 2:40 am Also, maybe you'd be interested in adding it to the wiki, for example, to some document called, Scripted objects with attachment, or something similar. And that example could be placed somewhere in the Power users hub.
https://wiki.freecadweb.org/Scripted_ob ... attachment
Thanks for the suggestions vocx.
Re: Part Attachment Feature with Custom Scripted Objects
I changed the headings to start at the ==second level==. First level headings is used only for the title.gbroques wrote: ↑Tue May 05, 2020 11:24 pm Great idea! I added this to the Wiki and included a link to it on the Power users hub:
https://wiki.freecadweb.org/Scripted_ob ... attachment
Also, hmm. Syntax highlighting works? This is actually good news. The highlighter was deactivated a long time ago because it didn't work correctly in the previous wiki server. But I never tested again after the new server was deployed.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Part Attachment Feature with Custom Scripted Objects
Good tip, thanks!
Yes, it's great
Re: Part Attachment Feature with Custom Scripted Objects
Following this example, how to set the attachment for an object?
example: I select an edge then a box. Then set the box attached "Z tangent" of the edge.
example: I select an edge then a box. Then set the box attached "Z tangent" of the edge.