Machining |
NC Review |
Generating a Catalog of User Defined NC OperationsDefining User Defined NC Operations |
Use Case |
AbstractThis article discusses the CAAMaiGenerateUserActivityCatalog use case and explains how to generate and upgrade a catalog of User Defined Operations. |
This use case is intended to help you to generate a new catalog of User Defined Operation. This involves the following:
This use case also shows how to upgrade an existing catalog of User Defined Operation.
[Top]
CAAMaiGenerateUserActivityCatalog is a use case of the CAAManufacturingItf.edu framework that illustrates how to generate a new catalog of User Defined operations and how to upgrade it.
[Top]
CAAMaiGenerateUserActivityCatalog enables the customer to generate a new activities catalog containing a new startup of User Defined Operation. This startup is named "UserActivity". The User Defined Operation use a "MfgHole" machining feature which is a standard machining feature defined in the Manufacturing.feat catalog. This operation has two strategy parameters ("Offset" and "NbOfCuts").
Then the use case allows to upgrade an existing activities catalog adding a new strategy parameter ("AdditionalParam").
[Top]
To launch CAAMaiGenerateUserActivityCatalog, you will need to:
//if ( Upgrade )
// SaveCatalog( &piClientCatalog, &NewPathCatalog );
//else
// CATDocumentServices::SaveAs(*lib,PathCatalog);
[Top]
The CAAMaiGenerateUserActivityCatalog use case is made of a main named CAAEMaiUserActivityCatalogMain located in the CAAMaiGenerateUserActivityCatalog.m module of the CAAManufacturingItf.edu framework:
Windows | InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CAAMaiGenerateUserActivityCatalog.m |
Unix | InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/CAAMaiGenerateUserActivityCatalog.m |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are four logical steps in CAAMaiGenerateUserActivityCatalog for the creation of a new activities catalog:
This use case also shows how to upgrade an existing catalog of User Defined Operation. The upgrade process is also based on four steps:
We now comment each of those sections by looking at the code.
[Top]
You have to create a new document of CATFct type.
//Creation of a new activities catalogue CATDocument* lib=NULL; CATDocumentServices::New("CATfct",lib); //Initialize root container CATIMfgCatalogFactories *piFact=NULL; CATString ClassName("CATMfgCatalogFactories"); CATInstantiateComponent (ClassName, CATIMfgCatalogFactories::ClassId(), (void**)& piFact); if (piFact == NULL) return 1; CATIContainer_var cont; HRESULT RC = piFact->CreateActivityRootCont(lib,cont); if (piFact) piFact->Release(); if (S_OK != RC || NULL_var == cont) return 2; CATInit_var pInitOnDoc = lib; if (NULL_var == pInitOnDoc) return 3; if (NULL_var != pInitOnDoc) { //pInitOnDoc->Init(FALSE); CATBaseUnknown * BidVar = pInitOnDoc -> GetRootContainer(CATIContainer::ClassName()); if (NULL != BidVar) { CATIContainer_var ActivityCatalog = BidVar; BidVar->Release(); BidVar = NULL; HRESULT RC = S_OK; CATICatalog_var hCatalogTemp = ActivityCatalog; if (NULL_var != hCatalogTemp) { CATUnicodeString TOTO = "CLIENT"; HRESULT HRID = hCatalogTemp-> SetClientId (&TOTO); } } } |
[Top]
To define the startup of a new User Defined Operation you should derivate from the startup "MfgUserDefinedMO" which is defined in the ManufacturingActivities.feat catalog. So ManufacturingActivities.feat is a prerequisit catalog and you need to load it.
If you want your User Defined Operation will use a predefined Machining Feature, the Manufacturing.feat is a prerequisit catalog too. In this use case, the Operation we want to define uses the "MfgHole" Machining Feature. But you can define your own Machining Feature by generating a new *.CATfct Catalog (This is fully described in the referenced article [2].). The only specific point is that your feature startup have to derivate from the "MachiningFeature" startup which is defined in Manufacturing.feat catalog).
In the new catalog we create a new startup of type "UserActivity" derivating from the startup "MfgUserDefinedMO" defined in the ManufacturingActivities.feat catalog and associate a predefined Machining Feature "MfgHole" to this startup.
You can also associate your own Machining Feature. In this case you have to first generating a new *.CATfct Catalog (This is fully described in the referenced article [2].) The only specific point is that your feature startup have to derivate from the "MachiningFeature" startup. To create this startup you should use the service CATMfgMachFeatureSUFactory. In this case, you have to load your own Catalog containing your Machining Feature startup by using the CATCatologFactoryServices, before trying to create the new activity startup. Your catalog becomes a prerequisit.
CATISpecObject *piNewStartUp = NULL; const CATUnicodeString pActivityTypeName = "UserActivity"; CATISPPActivityTypeFactory *piRootActivity = NULL; ... //============================================================================= // 2- Create a startup in this catalog //============================================================================= //Retrive Client Catalog if (NULL_var != cont) rc = cont -> QueryInterface(IID_CATICatalog, (void**) &piClientCatalog); if (FAILED(rc)) return 4; if (NULL == piClientCatalog) return 5; //Retrieve activities library document root container if (NULL_var != pInitOnDoc ) piRootActivity = (CATISPPActivityTypeFactory* )pInitOnDoc->GetRootContainer("CATISPPActivityTypeFactory"); else piClientCatalog -> QueryInterface( IID_CATISPPActivityTypeFactory, (void**) &piRootActivity ); CATIContainer *piActivityCont = NULL; if (NULL != piRootActivity) rc = piRootActivity -> QueryInterface(IID_CATIContainer, (void**) &piActivityCont); if (FAILED(rc)) return 6; if (NULL == piActivityCont) return 7; // Create the Startup const CATUnicodeString pActivitySuperTypeName = "MfgUserDefinedMO"; CATListOfCATUnicodeString pFeatureTypeNameList; pFeatureTypeNameList.Append("MfgHole"); CATIMfgStartupFactories *piSUFact=NULL; CATString ClassNameSU("CATMfgStartupFactories"); CATInstantiateComponent (ClassNameSU, CATIMfgStartupFactories::ClassId(), (void**)& piSUFact); if (NULL == piSUFact) return 8; rc = piSUFact->CreateMachiningOperationSU(&piNewStartUp, piClientCatalog, piActivityCont, pActivityTypeName, pActivitySuperTypeName, pFeatureTypeNameList); |
[Top]
Then we add two new strategy parameters "Offset" and "NbOfCuts" to the startup by using the interface CATIMfgManufacturingParameters . Those two parameters will be accessible in the strategy tabpage of the User Defined Operation edition panel.
In order to be able to use the interface CATIMfgManufacturingParameters you should have to create an instance of the class CATMfgManufacturingParameters with the interface CATIInstancianteComponent.
... //============================================================================= // 3- Add strategy parameters to this startup //============================================================================= // - Definition of the container in which we want to create instances CATICkeParmFactory_var ParmFactInst(cont); if (NULL_var == ParmFactInst) return 9; CATIMfgManufacturingParameters *piParm =NULL; ClassName = "CATMfgManufacturingParameters"; CATInstantiateComponent (ClassName, CATIMfgManufacturingParameters::ClassId(), (void**)& piParm); // Add strategy parameters CATBaseUnknown *pObj = NULL; if (NULL != piNewStartUp) rc = piNewStartUp -> QueryInterface(IID_CATBaseUnknown,(void**) &pObj); CATBaseUnknown_var hObj(pObj); CATICkeParmFactory_var FactL(piRootActivity); if (NULL != piParm && NULL_var != ParmFactInst) { CATICkeParm_var Param = ParmFactInst->CreateLength("Offset", 0.0); rc = piParm->AddStrategyParameterToActivity (hObj,"Offset",Param); Param = ParmFactInst->CreateInteger("NbOfCuts", 1); rc = piParm->AddStrategyParameterToActivity (hObj,"NbOfCuts",Param); piParm->Release(); } if (NULL != pObj) pObj -> Release(); pObj = NULL; if (NULL != piRootActivity) piRootActivity -> Release(); piRootActivity = NULL; |
[Top]
Finally you just have to save your catalog and delete the session.
... // Save the catalog CATUnicodeString PathCatalog ="E:\\tmp\\UserActivityCatalog.CATfct"; CATDocumentServices::SaveAs(*lib,PathCatalog); // delete the session, removes the opened documents also. // never forget to delete a creating session after usage. rc = ::Delete_Session("Session_perso"); |
[Top]
The upgrade process is also based on four steps:
Don't forget to change the value of the variable "Upgrade" to CATTrue in the code
of CAAMaiGenerateUserActivityCatalog.
// Set this variable to CATTrue to activate the upgrade mode |
The general API to update a feature catalog is used.
::UpgradeCatalog( &PathCatalog, &piClientCatalog, &ClientId ); |
Use the API RetrieveSU of CATICatalog interface to retrieve the startup.
const CATUnicodeString StartUpType = pActivityTypeName; CATBaseUnknown* pNewStartUpObject = NULL; rc = activityCatalog->RetrieveSU(&pNewStartUpObject,&StartUpType,CATISpecObject::ClassName()); if (SUCCEEDED(rc) && NULL != pNewStartUpObject) { rc = pNewStartUpObject->QueryInterface(IID_CATISpecObject,(void**)&piNewStartUp); pNewStartUpObject->Release(); pNewStartUpObject = NULL; cout << "Startup " << pActivityTypeName.ConvertToChar() << " retrieved" << endl; } |
This is done the same way than for creation.
Saving the catalog is done through the global function SaveCatalog.
CATUnicodeString NewPathCatalog ="C:\\tmp\\NewUserActivityCatalog.CATfct"; |
Don't forget to uncomment the two above lines, then to rename the generated file "NewUserActivityCatalog.CATfct" in "UserActivityCatalog.CATfct" and finally to copy it in the runtime view.
[Top]
This article provides an example on how to generate and upgrade a catalog of manufacturing User Defined Operations.
In this example we generate a catalog named "UserActivityCatalog.CATfct" that contains one startup of a User Defined Operation. The late type of this operation is "UserActivity". It derivates from the late type "MfgUserDefinedMO" as every user defined operation should do it. The "MfgUserDefinedMO" is a standard user defined operation. The corresponding startup of this operation is defined in the ManufacturingActivities.feat catalog.
For this user defined activity we authorized the "MfgHole" machining feature, which is a standard drilling machining feature defined in the Manufacturing.feat catalog.
We also add on this startup two different strategy parameters "Offset" and "NbOfCuts".
The way to upgrade this catalog in order to add another parameter for instance is also described.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[2] | Creating Features in an Applicative Container |
[Top] |
Version: 1 [Apr 2001] | Document created |
Version: 2 [Mar 2004] | Document modification |
Version: 3 [May 2007] | Add information on catalog upgrade |
[Top] |
Copyright © 2001, Dassault Systèmes. All rights reserved.