Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing CAM product

1 REPLY 1
SOLVED
Reply
Message 1 of 2
rolandas_vegis
148 Views, 1 Reply

Accessing CAM product

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?

1 REPLY 1
Message 2 of 2

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.

Post to forums  

Autodesk Design & Make Report