Mechanical Modeler |
Creating a New StartUp Deriving from a Mechanical StartUpCreating a StartUp and a StartUp factory interface |
|
Technical Article |
AbstractThe aim of this article is to describe all the steps to build a new mechanical feature: creating a new StartUp, creating a StartUp's catalog and creating a factory to create instances. This new feature, deriving from a mechanical feature, benefits from mechanical behaviors. The "Integrating a New Mechanical Feature in V5" [1] article lists them and explains the interfaces that the new feature must necessarily implement, or eventually implement, to be fully integrated in V5 and to behave as any other Dassault Systemes mechanical feature. This article is part of a set of documents which describe the Mechanical Modeler. Refer to the "Mechanical Modeler Overview" [2] article to have a view of all these articles. |
The next UML schema [Fig.1] presents a part of the mechanical feature tree:
To create a new feature type, you should derive from an existing public feature. These features and their public attributes can be found in the .CATSpec files. In the CAA encyclopedia, you will find references to these files in the Quick Reference section.
In the case of mechanical features, there are two files:
This file contains the names of mechanical StartUps that you can derive from. Depending on what you are going to do with your new CAA Feature, it might be judicious to choose the right ascendant feature to derive from...
Traditional Features:
Features Set - Dedicated to aggregation:
This file references the GSMGeom StartUp that you can also derive from.
How to choose ? The choice depends on the targeted domain in which the new feature should be part of:
By deriving only from the MechanicalFeature StartUp, you have a mechanical feature without geometry but integrated in some mechanical mechanisms. For example, you can insert this feature inside the MechanicalPart [9] and the feature will be displayed in the specification tree.
However, it is preferable to derive from MechanicalElement StartUp which is really dedicated to define non geometrical feature
There are two possibilities:
The new feature type has a form. Take a Groove for instance. From its input parameters, a Curve and a closed Sketch, one can easily derive a shape (a Form) by sliding the Sketch along the Curve. The resulting solid must then be operated with the Part's shape as it exists prior to the definition of the Groove, by removing matter (thanks to a boolean difference operation in this case).
In contrast to form features, contextual features, cannot be applied by first computing a standalone footprint, and then operating it with the geometrical features set. Fillets, Drafts and generally all Dress up features fall into this category, because their shape is determined not only by their own input parameters, but also by the local topology of the target geometrical features set (hence their name). Contextual features do not have a footprint.
There are two possibilities in this case as well:
This allows you to benefit from the following behaviors of the Generative Shape Design (GSD) features [3]:
As well as the future Generative Shape Design (GSD) behaviors ...
There are two reasons to derive from this feature:
[Top]
The StartUp is a feature prototype that describes the data structure of all feature instances that will be created from it. The new StartUp must be created in a .CATFct catalog file. Here are the steps needed to realize the creation of a new StartUp:
AddAttribute
method)You can execute the forth first operations in a main batch program which will create/modify the .CATFct file. This file is used as input to the factory that will instantiate the StartUp in a document.
These five steps are described in more details in the following articles:
Once created, the StartUp should be able to be instantiated; See the "Creating the New Derived StartUp Factory" section below. Each feature instance should also be modifiable, as you will see in the next section.
[Top]
The new feature has certainly its own specific attributes (see step 3 in the previous section). To valuate them or to retrieve their values, it is recommended to create an interface of type, as compared to an interface of behavior. This interface enables you to access all specific attributes of the feature.
To achieve this goal, two steps are necessary:
Refer to the "Creating an Interface" article [7], to create the header, the source and the .trsc files of this interface.
This interface will be implemented on the new StartUp, so in the implementation source file you will find:
... CATImplementClass ( SourceName, DataExtension , CATBaseUnknown , NameOfTheNewStartup); ... |
The CATImplementClass
macro means that SourceName
is a data extension of
NameOfTheNewStartup
. The third argument
must always be set to CATBaseUnknown or CATNull for any kind of
extension. NameOfTheNewStartup
is the name set in the CATOsmSUFactory
global function (see step 4 of the previous section)
[Top]
This paragraph explains how to create instances of the new StartUp. To achieve this goal, two steps are necessary:
In most cases, this interface contains only one method which has as input arguments, the values needed to initialize the attributes of the new instance and as output argument, the new instance. Here is an example:
#ifndef CAAIXXFactory_h #define CAAIXXFactory_h #include "CATBaseUnknown.h" class CATISpecObject ; extern ExportedByCAADLL IID IID_CAAIXXFactory; class ExportedByCAADLL CAAIXXFactory : public CATBaseUnknown { CATDeclareInterface; public : virtual HRESULT CreateMyNewFeature(...,..., CATISpecObject **pISpecObjectOnInstance) = 0; }; #endif |
The last argument of this method, pISpecObjectOnInstance
, is the newly created instance.
Refer to the "Creating an Interface" article [7], to create the src and the .trsc files .
This section answers the following questions:
CreateMyNewFeature
method ?This factory interface will be implemented on the specification container named CATPrtCont
[8]. So in the implementation source file, you will have
a declaration such as:
CATImplementClass ( CAAEXXFactory, DataExtension , CATBaseUnknown , CATPrtCont ); #include "TIE_CAAIXXFactory.h" TIE_CAAIXXFactory( CAAEXXFactory); |
The CATImplementClass
macro means that CAAEXXFactory
is a data extension of CATPrtCont
. The third argument
must always be set to CATBaseUnknown or CATNull for any kind of
extension. The TIE macro is needed to tie the implementation to its interface.
Do not forget to modify the interface dictionary to declare
that CATPrtCont
implements the interface factory in the
library which contains the implementation of the interface.
CATPrtCont CAAIXXFactory libYYYY |
The generic contents of the CreateMyNewFeature
method can be the
following:
HRESULT CAAEXXFactory::CreateMyNewFeature( ...,..., CATISpecObject ** pISpecObjectOnInstance ) {
|
1) Get the CATIContainer interface pointer on "this"
... CATIContainer * pIContainer = NULL ; rc = QueryInterface( IID_CATIContainer , ( void**)&pIContainer); ... |
2) Open the catalog which contains the newly derived StartUp
CATICatalog * pICatalog = NULL; CATUnicodeString StorageName = "NameOfTheCatalog.CATfct"; CATUnicodeString ClientId = "MyCatalogClientId"; rc = ::AccessCatalog( &StorageName, &ClientId, pIContainer, &pICatalog); |
To open the catalog, you can use the AccessCatalog
global function. The
parameters of this function are:
CreateCatalog
global function but without the complete path.
see the "Create a Catalog for the New Derived StartUp"
step SetClientId
method - see the "Create a Catalog for the New Derived StartUp"
step3) Retrieve the newly derived StartUp
... CATBaseUnknown *pStartup = NULL; CATUnicodeString StartupType = "NameOfTheNewStartup"; rc = pICatalog->RetrieveSU( &pStartup , &StartupType ,"CATISpecObject" ); ... |
The RetrieveSU
method retrieves from the catalog the StartUp
whose the name was defined in the "Use the Generic StartUp Factory to Create the New Derived StartUp"
step.
4) Create an instance of the newly derived StartUp
... CATISpecObject *pISpecObjectOnStartup = NULL; rc = pStartup->QueryInterface( IID_CATISpecObject , ( void**)&pISpecObjectOnStartup ); (*pISpecObjectOnInstance) = pISpecObjectOnStartup->Instanciate( NULL_string , pIContainer ); ... |
pISpecObjectOnInstance
is the output argument of the method.
5) Subscribes to repository for Configuration Data Storage
As Mechanical Modeler and CGM algorithms are versioned, feature instances are
"software level dependant".
Consequently, feature instances must store the software configuration to choose
the right level to use, particularly on build process.[10]
This storage must be initialize just after instantiation thanks to "CreateConfigurationData"
method of CATMmrAlgoConfigServices.
... rc = CATMmrAlgoConfigServices::CreateConfigurationData(*pISpecObjectOnInstance); if( FAILED(rc) ) return rc; ... |
pISpecObjectOnInstance
is the output argument of the method.
6) Gets Feature Type Information for BackUp / StartUp management - Only if you use a Geometrical Feature
BackUp / StartUp is a specific mode which occurs when something goes wrong
with the CAA feature (when startup catalog and code are not longer available on
the runtime view) [11]
If your feature derived from a "geometrical startup" ( GeometricalElement3D
or GSMGeom ) , you need to define and store its type according to
CATIInputDescription implementation. This information, stored on the
instance, will be useful in BackUpStartUp Mode to determine which
behaviours are authorized.
This operation is done after instantiation, calling CATMmrFeatureAttributes::SetFeatureType
... CATIInputDescription* pInputDescriptionOnInstance = NULL; rc = (*pISpecObjectOnInstance)->QueryInterface( IID_CATIInputDescription, (void**) &pInputDescriptionOnInstance); ... CATIInputDescription::FeatureType Feature_type = CATIInputDescription::FeatureType_Unset; rc = pInputDescriptionOnInstance -> GetFeatureType(Feature_type); ... rc = CATMmrFeatureAttributes::SetFeatureType(*pISpecObjectOnInstance, Feature_type); ... |
Note: This step is not to do if your feature is not geometrical or if it is a "Solid feature" i.e. derivate from MechanicalFormFeature, MechanicalContextualFeature.
7) Set default values for the attributes of the new feature instance
By using the interface described in "Creating an Interface of Type" section, you can apply default values for the attributes.
It is recommended that the factory does not aggregate the new instance in a geometrical features set or in a MechanicalSet[9].
[Top]
A new mechanical feature should derive from one of the five available public mechanical StartUps list below:
You can also create a new mechanical feature designed to aggregate features. In this case, you should derived from GSMTool or MechanicalSet startUps, depending on what kind of features you want to aggregate.
The main steps necessary to create the new StartUp are:
[Top]
Version: 1 [Dec 2002] | Document created |
Version: 2 [Jan 2007] | Document updated (Algorithm Services and BackUp/StartUp data) |
Version: 3 [Mar 2007] | Document updated (New Derivable StartUp - MechanicalElement & MechanicalSet) |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.