Mechanical Design |
Drafting |
Editing Dimension Dress-UpHow to use dimension interfaces |
Use Case |
AbstractThis article discusses the CAADrwDimDressupCmd.cpp use case. This use case explains how to edit a dimension dress-up. |
In this use case you will learn how to modify the dimension dress-up parameters.
[Top]
[Top]
CAADrwDimDressupCmd is a use case of the CAADraftingInterfaces.edu framework that illustrates DraftingInterfaces framework capabilities.
[Top]
This sample waits for a dimension selection and modifies the dress-up as follows:
|
[Top]
To launch CAADrwDimDressupCmd, you will need to set up the build time environment, then compile CAADrwDimDressupCmd and CAADrwAddin along with its prerequisites, set up the run time environment, and then include the command in a workbench [1].
[Top]
The CAADrwDimDressupCmduse case is made of two source files named CAADrwDimDressupCmd.h and CAADrwDimDressupCmd.cpp located in the CAADrwDimDressup.m module of the CAADraftingInterfaces.edu framework:
Windows | InstallRootDirectory\CAADraftingInterfaces.edu\CAADrwDimDressup.m\ |
Unix | InstallRootDirectory/CAADraftingInterfaces.edu/CAADrwDimDressup.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are 11 steps in CAADrwDimDressupCmd:
[Top]
void CAADrwDimDressupCmd::BuildGraph() { // Creation of the acquisition agent _pObjectAgent = new CATPathElementAgent("_ObjectAgent A"); _pObjectAgent ->SetBehavior( CATDlgEngWithPrevaluation | CATDlgEngMultiAcquisition | CATDlgEngWithCSO); // We want to select dimensions _pObjectAgent ->AddElementType("CATIDrwDimDimension"); AddCSOClient(_pObjectAgent); // States definition CATDialogState* state1 = GetInitialState("Sel dimension"); state1->AddDialogAgent(_pObjectAgent); // Transition definition AddTransition(state1, NULL, IsOutputSetCondition(_pObjectAgent), Action((ActionMethod)&CAADrwDimDressupCmd::DressUp, NULL, NULL)); } |
In this section we create a CATPathElementAgent and set the corresponding element type to CATIDrwDimDimension. So only dimensions could be selected.
[Top]
boolean CAADrwDimDressupCmd::DressUp(void *) { // We get the Selected set of objects CATSO* pObjSO = _pObjectAgent->GetListOfValues(); CATPathElement *pElemPath = NULL; if (pObjSO) { // There is a selection, we will scan it from the beginning pObjSO->InitElementList(); while (NULL != (pElemPath = (CATPathElement*)pObjSO->NextElement())) { // Make sure the element is dimension CATIDrwDimDimension *piDim = (CATIDrwDimDimension *)pElemPath->FindElement(IID_CATIDrwDimDimension); if (NULL != piDim) { ... |
The acquisition agent did put the selected dimension into the CSO. So we get the set of object and loop on it.
[Top]
... // Text properties CATIDrwTextProperties_var spTextProperties = piDim; spTextProperties->SetFontSize(5); spTextProperties->SetColor(255, 0, 0, 255); spTextProperties->SetFrameType(CATDrwRectangle); ... |
The dimension implements the CATIDrwTextProperties interface. Using this interface, we modify the font size, color and the text frame format.
[Top]
... // Dual value piDim->ShowDualValue(); ... |
The dual value is set using the CATIDrwDimDimension interface.
[Top]
... // Tolerance piDim->AddTolerance("h7","g6",1,1); ... |
The tolerance is set using the CATIDrwDimDimension interface.
[Top]
... // We get the dim value CATIDrwDimValue_var spDimValue = piDim->GetValue(); spDimValue->SetDualValueDisplay(CATDrwDimDualSideBySide); // The main value CATIDrwDimValueComponent_var spMainValue = spDimValue->GetFaceComponent(); CATIDrwDimText_var spMainText = spMainValue->GetText(); spMainText->SetPSText("L=", ""); spMainText->SetBAULText("", "", "Up", "Down"); ... |
The CATGraphicAttributeSet will be used to convert RGBA data from a
4-integer representation to a 1-integer representation. First we get the
dimension value. This feature manages the main and dual value representations.
Then we get the main value from the dimension value. Using SetPSText
we set:
Using SetBAULText
we set:
[Top]
... // The dual value CATIDrwDimValueComponent_var spDualValue = spDimValue->GetDualComponent(); CATIDrwDimFormat_var spDualFormat = spDualValue->GetFormat(); spDualFormat->SetUnit(CATDrwDimUnitINCH); ... |
We get the dual value from the dimension value and modify the format putting the unit to "INCH".
[Top]
... // Useful to convert RGBA(4-int)<->RGBA(1-int) CATGraphicAttributeSet attrSet; // DimensionLine CATIDrwDimDimensionLine_var spDimLine = piDim->GetDimensionLine(); attrSet.SetColorRGBA(255,0,0,255); spDimLine->SetGraphicParameters(attrSet.GetColorRGBA(), 0.2); spDimLine->SetSymbol(CATDrwDimSymbCircledCross,CATDrwDimSymbCircledCross); attrSet.SetColorRGBA(0,255,0,255); spDimLine->SetSymbolsGraphicParameters(attrSet.GetColorRGBA(), 0.1, attrSet.GetColorRGBA(), 0.1); ... |
We get the dimension line interface from the dimension. Using the CATIDrwDimDimensionLine interface we modify :
[Top]
... // ExtentionLine CATIDrwDimExtensionLine_var spExtLine = piDim->GetExtensionLine(); attrSet.SetColorRGBA(0,255,255,255); spExtLine->SetGraphicParameters(attrSet.GetColorRGBA(), 0.2); spExtLine->SetGap(4); spExtLine->SetOverRun(4); ... |
We get the extension line interface from the dimension.
Using the CATIDrwDimExtensionLine interface we modify :
[Top]
... // Funnel CATIDrwDimExtensionLineLinear_var spLinearExtLine = spExtLine; spLinearExtLine->SetFunnel(1); ... |
This is a distance dimension. So the extension line implements CATIDrwDimExtensionLine.
CATIDrwDimExtensionLineLinear::SetFunnel(1)
sets the funnel at
true.
[Top]
... // Let's update the dimension after spec modifications CATISpecObject_var spDimSpec = piDim; spDimSpec->Update(); piDim->Release(); } } _pObjectAgent -> InitializeAcquisition(); return TRUE; } return FALSE; } |
We have to update the dimension to take into account the dress-up modifications.
[Top]
This use case shows how to edit a dimension dress-up. The main dimension interfaces are CATIDrwDimDimension, CATIDrwTextProperties, CATIDrwDimValue, CATIDrwDimValueComponent, CATIDrwDimText, CATIDrwDimFormat, CATIDrwDimDimensionLine, CATIDrwDimExtensionLine, CATIDrwDimExtensionLineLinear and CATISpecObject.
[Top]
[1] | Building and Lauching CAA V5 Samples |
[2] | Implementing the Statechart Diagram |
[Top] |
Version: 1 [Jan 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.