Mechanical Design |
Drafting |
Editing Callout in Generative ViewsHow to access and modify callouts in generative view |
Use Case |
AbstractThis article discusses the CAADrwCallout use case. This use case explains how to retrieve these elements in a generative view. |
This use case is intended to show you how to access callouts in generative views.
[Top]
CAADrwCallout is a use case of the CAADraftingInterfaces.edu framework that illustrates DraftingInterfaces framework capabilities.
[Top]
Fig. 1: Initial Document |
|
Fig. 1 represents a Drawing document containing generative views created from a Part document. |
Fig. 2 The Document modified by the Use Case |
|
Fig. 2 represents the Drawing document modified by the use case program. All Callouts have been modified by ApplyStyle internal method defined in this Use Case, thus, arrows of callout have been changed. |
[Top]
To launch CAADrwCallout, you will need to set up the build time environment, then compile CAADrwCallout along with its prerequisites, set up the run time environment, and then execute the use case [1].
When you launch the use case, pass the full pathname of the Drawing file as argument. A Drawing file is delivery in the following path: CAADraftingInterfaces.edu\FunctionTests\InputData\DrawingForCalloutUseCase.CATDrawing.
e:> mkrun -c cmd CAADrwCallout c:\...\DrawingForCalloutUseCase.CATDrawing c:\DrawingTestOutput.CATDrawing |
$ mkrun -c cmd CAADrwCallout /u/users/.../DrawingForCalloutUseCase.CATDrawing /u/users/DrawingTestOutput.CATDrawing |
[Top]
The CAADrwCallout use case is made of a single source file named CAADrwCallout.cpp located in the CAADrwCallout.m module of the CAADraftingInterfaces.edu framework:
Windows | InstallRootDirectory\CAADraftingInterfaces.edu\CAADrwCallout.m\ |
Unix | InstallRootDirectory/CAADraftingInterfaces.edu/CAADrwCallout.m/ |
where InstallRootDirectory
is the directory where the CAA
CD-ROM is installed.
[Top]
There are seven steps in CAADrwCallout:
[Top]
int main(int iArgc, // Number of arguments (3) char** iArgv) // Path to the existing file *.CATDrawing document { // Check arguments if(3 != iArgc) return 1; const char *pfileNameDrawing = iArgv[1]; const char *pfileNameOut = iArgv[2]; // return code error int rc =0; // CREATE THE SESSION // ===================== CATSession *pSampleSession = NULL; HRESULT hr = ::Create_Session("SampleSession",pSampleSession); if (FAILED(hr)) return 1; CATIDftDrawing *piDrawing = NULL; CATIDftDocumentServices *piDftDocServices = NULL; CATDocument* pDocDrawing = NULL; if (FAILED(CATDocumentServices::OpenDocument(pfileNameDrawing, pDocDrawing))) { // Ends session ::Delete_Session("SampleSession"); return 2; } ... |
This section represents the usual sequence for loading a CATIA document [2].
[Top]
... CATIDftDrawing *piDrawing = NULL; CATIDftDocumentServices *piDftDocServices = NULL; if (SUCCEEDED(pDocDrawing->QueryInterface(IID_CATIDftDocumentServices,(void **)&piDftDocServices))) { if (SUCCEEDED(piDftDocServices->GetDrawing(IID_CATIDftDrawing, (void **)&piDrawing))) { piDftDocServices->Release(); piDftDocServices=NULL; } ... |
The root feature of a Drawing document is the Drawing itself, that is, the
feature that implements the CATIDftDrawing interface. We can get a
pointer to CATIDftDrawing using the CATIDftDocumentServices
interface, which is implemented by the document. The GetDrawing
method first argument is the CATIDftDrawing interface IID.
[Top]
... // LOOP ON ALL VIEWS IN DRAWING // ================================ CATIUnknownList * piListOfView = NULL; if (SUCCEEDED(piDrawing->GetViews(&piListOfView))) { unsigned int piViewListSize = 0; piListOfView->Count(&piViewListSize); IUnknown * itemView = NULL; CATIDftView *piCurrentView = NULL; // Loop on all callouts of the processed view // ----------------------------------------------- for(unsigned int numview=0 ; numview<piViewListSize ; numview++) { if( SUCCEEDED( piListOfView->Item(numview, &itemView) ) ) { if (itemView) { if (SUCCEEDED(itemView->QueryInterface(IID_CATIDftView,(void **)&piCurrentView))) { CATIUnknownList * piListOfCallout = NULL; // Get list of callouts of the view processed // ---------------------------------------------- if( SUCCEEDED( piCurrentView->GetComponents(IID_CATIDrwCalloutAccess, &piListOfCallout) ) ) { if (piListOfCallout) { unsigned int piListSize = 0; piListOfCallout->Count(&piListSize); CATIDrwCalloutAccess* piCallout = NULL; IUnknown * item = NULL; // Loop on all callouts of the view processed // ---------------------------------------------- for(unsigned int i=0 ; i<piListSize ; i++) { if( SUCCEEDED( piListOfCallout->Item(i, &item) ) ) { if(SUCCEEDED( item->QueryInterface(IID_CATIDrwCalloutAccess, (void**) & piCallout) ) ) { ... |
The GetViews method returns the list of all views in Drawing document. The GetComponents method of CATIDftView interface is a generic method to return elements identified by his IID.
[Top]
... // Get the view associated with the callout // ------------------------------------------- CATIDftView *piDefView=NULL; if (SUCCEEDED(piCallout->GetAssociatedView(&piDefView))) { piDefView->GetViewName(&pViewName); ViewName.BuildFromWChar(pViewName); cerr << " View name associated to the processed callout: " << ViewName.CastToCharPtr() << endl; ... |
GetAssociatedView method defined in CATIDrwCalloutAccess interface returns the View from which Callout is defined. In case of Broken View, Callout are created in the same View, So GetAssociatedView is useless.
[Top]
... CATIGenerSpec *piGenerSpec=NULL; if (SUCCEEDED(piDefView->GetGenerSpec(&piGenerSpec))) { // Get callout type // ------------------- CATIDrwCalloutAccess::CATDrwCalloutType calloutType; piCallout->GetCalloutType(calloutType); if (calloutType == CATIDrwCalloutAccess::SectionCallout) { CATListPtrCATMathPoint2D ListOfPoints; int depli=0; CATMathDirection vecpro; // Get geometric informations about section profile // --------------------------------------------------------- if (SUCCEEDED(piGenerSpec->GetSectionProfile(ListOfPoints,depli,vecpro))) { int NbPt = ListOfPoints.Size(); for (int numpt=1 ; numpt<=NbPt ; numpt++) { CATMathPoint2D *tmpt = ListOfPoints[numpt]; cerr << " Number point = " << numpt << ", X= "<< tmpt->GetX() << "Y = " << tmpt->GetY() << endl; // Memory clean if (tmpt) delete tmpt , tmpt=NULL; } } } ... |
From the Associated view to the Callout, It is possible to retrieve the definition of the View. For example for a Section View, the Cutting Profile may be obtained by GetSectionProfile method defined in CATIGenerSpec Interface.
Note: depli and vecpro arguments are dedicated to give information about the type of the profile (Aligned Section View or Offset Section View)
... int NbTexts; rc = piCallout->GetNumberOfTexts(NbTexts); if (SUCCEEDED(rc)) { for (int iNumText = 1; iNumText <= NbTexts ; iNumText++) { CATIDrwAnnotationComponent *piAnnot=NULL; rc = piCallout->GetCalloutText(iNumText,&piAnnot); if (SUCCEEDED(rc)) { CATIDrwSimpleText *piText=NULL; CATIDftText *piDftText = NULL; // Callout texts may be based on simple text instance until V5R13 CATIA level. if (SUCCEEDED(piAnnot->QueryInterface(IID_CATIDrwSimpleText,(void **)&piText))) { CATIDrwSubText_var spSubText; spSubText = piText->GetSubText(1); CATUnicodeString textName = spSubText->GetText(); cerr << " texte name = " << textName.CastToCharPtr() << endl; piText->Release(); piText=NULL; } else if(SUCCEEDED(piAnnot->QueryInterface(IID_CATIDftText,(void **)&piDftText))) { wchar_t *ptextName=NULL; if (SUCCEEDED(piDftText->GetString(&ptextName))) { CATUnicodeString strTextName; strTextName.BuildFromWChar(ptextName); cerr << " texte name = " <<strTextName.CastToCharPtr() << endl; if (ptextName) delete[] ptextName; ptextName = NULL; } piDftText->Release();piDftText=NULL; } piAnnot->Release();piAnnot=NULL; } } // Modification of the callout Representation int thickness = 2; rc = piCallout->SetProfileThickness(thickness); int linetype = 3; rc = piCallout->SetProfileLineType(linetype); int NbArrows; rc =piCallout->GetNumberOfArrow(NbArrows); if (SUCCEEDED(rc)) { for (int iNumArrow = 1; iNumArrow <= NbArrows ; iNumArrow++) { double ArrowLength,ArrowLengthSymb,ArrowAngleSymb,ArrowOrientation; CATSymbolType ArrowTypeSymb; ArrowLength=35.0; ArrowTypeSymb=FILLED_ARROW; ArrowLengthSymb=6.0; ArrowAngleSymb=45.0; rc = piCallout->SetInfoOfArrow(iNumArrow,ArrowLength,ArrowTypeSymb,ArrowLengthSymb,ArrowAngleSymb); } if (NbArrows != 0) { CATDftArrowExtremity calloutAttachment; rc = piCallout->GetArrowsAttachment(calloutAttachment); calloutAttachment= CATDftArrowTail; rc = piCallout->SetArrowsAttachment(calloutAttachment); } } } ... |
Note: Up to V5R13, associated texts to the Callout may be based on simple text instance.
[Top]
... // Save the result rc = CATDocumentServices::SaveAs(*pDoc, (char *)fileName); ... // Check rc rc = CATDocumentServices::Remove (*pDoc); ... // Check rc // Ends session and drops document rc = ::Delete_Session("SampleSession"); ... // Check rc return 0; } |
This section represents the usual sequence for saving a newly created CATIA document [3].
[Top]
This use case shows the way to :
[Top]
[1] | Building and Lauching CAA V5 Samples |
[2] | Load an existing Document |
[Top] |
Version: 1 [May 2004] | Document created |
[Top] |
Copyright © 2004, Dassault Systèmes. All rights reserved.