Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Creo VB API Type Library for Creo Parametric 8.0.0.0 Version 1.0
Creo Parametric 9.0.0.2
The Creo API call to
IpfcBaseSession m_session;
m_session.ImportNewModel(filePath, (int)EpfcNewModelImportType.EpfcIMPORT_NEW_STEP, (int)EpfcModelType.EpfcMDL_ASSEMBLY, "temp", null);does not match the importing that I did by hand. I get the following error message (repeated for each feature as it tries to import the file, there are 155 features/bodies in the step file) which doesn't happen when I import the step by hand.
"Warning: Design intent is unclear in FEATURE_155. Use Geometry Checks command on the Tools Tab in Part mode for more information."
Why does this method check design intent when opening the file through the UI doesn't?
Full use case:
I'd like to use Creo to apply boolean operations to STEP bodies. I've added all of these bodies to a single STEP file and would like to import it into Creo via the COM API using C#.
Before getting into the code, I've confirmed my use case works using Creo with the following steps.
1. Use the "File Open" dialog to select my step file.
2. Import my step file as an assembly with automatic import type using the "Import New Model" dialog.
3. Creo now processes each feature in the step file and creates an assembly with each body in the step being a separate part.
4. Model > Component > Component Operations > Boolean Operations.
5. Select the "Cut" operation and set "Modified Models" to the part I want to subtract from.
6. Set "Modifying Components" to the parts I want to subtract with and accept.
7. Creo now applies the cuts
8. Delete or hide the parts that were used for the cut. Leaving me with a single final part.
These are the steps I want to recreate with the COM API. I am new to the Creo and its API but used to C#. I'd like to know why it doesn't match my operations when done through the UI.
This is my code so far
using System;
using pfcls;
string m_exePath = @"C:\Program Files\PTC\Creo 9.0.2.0\Parametric\bin\parametric.exe";
IpfcAsyncConnection m_asyncConnection;
IpfcBaseSession m_session;
string filePath = ""; // Hidden for privacy
try
{
CCpfcAsyncConnection cAC = new CCpfcAsyncConnection();
m_asyncConnection = cAC.Start(m_exePath, null);
m_session = (IpfcBaseSession)m_asyncConnection.Session;
IpfcModel model = m_session.ImportNewModel(filePath,
(int)EpfcNewModelImportType.EpfcIMPORT_NEW_STEP,
(int)EpfcModelType.EpfcMDL_ASSEMBLY,
"tmp2115",
null);
}
catch (Exception e)
{
throw e;
}I'd appreciate any insight. Is there a different way to import that would match the way I did it in the UI? Or do I need to set something else up different or change settings before the import in the code?
Thank you and happy holidays!
Tristan | Software Developer
