Jump to content
3DCoat Forums

Python scripting - API ( Addon development)


Recommended Posts

  • Member

Hello, I'm just wondering—how can I skip the "Save As" dialog menu when saving a layer to .obj, .fbx, etc.? I just want to programmatically pass the path for the 3D model without dealing with dialog menus.

Also, is it necessary to switch to the Retopo room for model decimation, or can we avoid that as well and just set the decimation level as an argument?

Same goes for importing into the current level—how can I programmatically use an object path as an argument and avoid the dialog menu?

Thanks

Link to comment
Share on other sites

  • Member
Carlosan
This post was recognized by Carlosan!

crudodev was awarded the badge 'Great Content' and 1 points.

Okay, I found a solution in the documentation. To prevent the pop-up dialog menu and pass the file path, we can use the following method:

coat.ui.setFileForFileDialog(se.exportMesh)
  • Like 1
Link to comment
Share on other sites

  • Member

Just playing around with the Python API—Is it possible to create one Python add-on that has its own submenu with different buttons? Or do I have to create a separate "script" for each action?

Also, I found that only with C++ we can create custom sculpt tools integrated into the UI, similar to the tree generator C++ add-on from the examples. Correct me if I'm wrong.

Link to comment
Share on other sites

You mean this ?

image.png

Scripts Menu > CreatePythonScript > Basic... > Dialogs.py

image.png

  • Like 1
Link to comment
Share on other sites

  • Member

I meant more like this: I made a workaround where each button is an independent script (Python package) in the context of 3DCoat.

But ideally, it would be great to create a custom menu—one add-on with multiple modules and subpackages.

Edit: Ah, I see! There are examples showing how to insert into the Tools panel and menus. Thanks!


image.png.05bf0593ddd8e634f000e28cdb806246.png

  • Like 1
Link to comment
Share on other sites

On 3/22/2025 at 8:14 AM, crudodev said:

Hello, I'm just wondering—how can I skip the "Save As" dialog menu when saving a layer to .obj, .fbx, etc.? I just want to programmatically pass the path for the 3D model without dealing with dialog menus.

Also, is it necessary to switch to the Retopo room for model decimation, or can we avoid that as well and just set the decimation level as an argument?

Same goes for importing into the current level—how can I programmatically use an object path as an argument and avoid the dialog menu?

Thanks

You can use low-level APIs, as it is done in the Reality Capture module.
3DCoat_install_folder\UserPrefs\Scripts\Modules\RealityCapture\PhotosTo3DExt.py

https://pilgway.com/files/3dcoat/PythonAPI/classcoat_1_1_paint_room.html

if you need additional low-level API functionality - let me know

PLOw.png

  • Like 2
Link to comment
Share on other sites

  • Member
Posted (edited)

How can I import extra modules? For example PySide6?
My goal is to create an integration with ShotGrid (Flow Production Tracking) and the toolkit for Pipeline flows.
https://help.autodesk.com/view/SGSUB/ENU/?guid=SG_Automotive_am_getting_started_am_integrations_intro_html

Community Integrations: 
https://help.autodesk.com/view/SGDEV/ENU/?guid=SGD_si_integrations_community_shared_integrations_html

Edited by MJonathan
  • Like 1
Link to comment
Share on other sites

  • Member
16 hours ago, carrots said:

You can use low-level APIs, as it is done in the Reality Capture module.
3DCoat_install_folder\UserPrefs\Scripts\Modules\RealityCapture\PhotosTo3DExt.py

https://pilgway.com/files/3dcoat/PythonAPI/classcoat_1_1_paint_room.html

if you need additional low-level API functionality - let me know

PLOw.png

Thanks. This is useful.

I just found your add-on system quite similar to something I built for Autodesk Maya, which helps manage scripts in a more simplified way. If you're interested, I have an article about it link

Also, I’m wondering if it’s possible to create a custom context menu with submenus, separators, etc.? I saw that it's possible to insert menu items, but I couldn’t find how to manage submenus, separators etc.

  • Like 1
Link to comment
Share on other sites

Ok, I'll make some examples of custom extensions based on PySide6, custom menu and post them here.

  • Like 2
Link to comment
Share on other sites

  • Member
Posted (edited)
9 hours ago, carrots said:

Ok, I'll make some examples of custom extensions based on PySide6, custom menu and post them here.

Just quick question:

- I found that on macOS, the Addon context menu doesn't parse the standard Examples scripts, so they don't show up in the Addon menu.

- The command coat.ui.toRoom(f"{ROOM_NAME}") doesn't work on macOS — I have to use coat.ui.cmd("$SETPAGE_Sculpt") instead.

- I also noticed that in the examples, we use coat.ui.toRoom("Sculpt") for the SCULPT room, but it doesn't work — I have to use "Voxels" instead. What’s the difference between them? Is this an undocumented change?

3D Coat 2024.31

Edited by crudodev
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...