Hello,
Why is it not possible to access the CAM product from API if document does not have any Setups created in Manufacture workspace?
We are trying to automate some CAM features and as it stands to access CAM API it seems the document needs to have at least an empty Setup created, otherwise I'm getting an error: failed to find product.
In CAM samples I found code:
Ptr<CAM> camProduct = products->itemByProductType("CAMProductType");
if (!camProduct)
{
ui->messageBox(
"There are no CAM operations in the active document. This script requires the active document to contain "
"at least one CAM operation.",
"No CAM Operations Exist",
MessageBoxButtonTypes::OKButtonType,
MessageBoxIconTypes::CriticalIconType);
return false;
}
Is there a workaround for this?
Solved! Go to Solution.
Solved by Jorge_Jaramillo. Go to Solution.
Hi,
If the CAM product is not created yet in the document, you can switch to the CAM Environment and it will be created automatically.
Here is my test over a new document:
app.log('Before:')
for pro in app.activeDocument.products:
app.log(f' {pro}')
ws = ui.workspaces.itemById("CAMEnvironment")
ws.activate()
app.log('After:')
for pro in app.activeDocument.products:
app.log(f' {pro}')
This is the result:
Before:
<adsk.fusion.Design; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::fusion::Design > *' at 0x000001CD976EE460> >
After:
<adsk.fusion.Design; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::fusion::Design > *' at 0x000001CD976EE8E0> >
<adsk.cam.CAM; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::cam::CAM > *' at 0x000001CD976EDE60> >
Regards,
Jorge Jaramillo
Can't find what you're looking for? Ask the community or share your knowledge.