Page 1 of 1

Part Attachment Feature with Custom Scripted Objects

Posted: Tue May 05, 2020 2:21 am
by gbroques
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!

Re: Part Attachment Feature with Custom Scripted Objects

Posted: Tue May 05, 2020 2:40 am
by vocx
gbroques wrote: Tue May 05, 2020 2:21 am ...
See the following repository for detail:
https://github.com/gbroques/freecad-par ... on-example
...
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.

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.

Re: Part Attachment Feature with Custom Scripted Objects

Posted: Tue May 05, 2020 11:24 pm
by gbroques
vocx wrote: Tue May 05, 2020 2:40 am 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.
Good point. I renamed the extension to .py in the GitHub repository for syntax highlighting purposes.

---
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.
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

Thanks for the suggestions vocx. :)

Re: Part Attachment Feature with Custom Scripted Objects

Posted: Tue May 05, 2020 11:58 pm
by vocx
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
I changed the headings to start at the ==second level==. First level headings is used only for the title.

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.

Re: Part Attachment Feature with Custom Scripted Objects

Posted: Wed May 06, 2020 2:25 am
by gbroques
vocx wrote: Tue May 05, 2020 11:58 pm I changed the headings to start at the ==second level==. First level headings is used only for the title.
Good tip, thanks!
vocx wrote: Tue May 05, 2020 11:58 pm 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.
Yes, it's great :)

Re: Part Attachment Feature with Custom Scripted Objects

Posted: Sat Aug 22, 2020 9:24 am
by Vincent B
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. :roll: