Я создал проект, в котором я хочу создать точечную функцию, используя язык программирования, такой как C ++.
Я создал свою структуру & модуль.
Я добавил компонент, который был связан с TIE_CATIAfrGeneralWksAddin.
Затем я добавил команду создания & Создан метод панели инструментов и включены вспомогательные файлы.
Затем я добавил еще один исходный файл, включая метод Activate, который содержит мой код создания точки.
Когда я запускаю Catia после построения его в меню инструментов, я вижу свою настраиваемую кнопку, которая создаст точку, но когда я нажимаю на эту кнопку, она должна создать точку, насколько мне известно, и выполнить метод активации.
Но когда я нажимаю на эту кнопку, появляется сообщение об ошибке «невозможно получить доступ к команде»
кнопка
ошибка при получении в катии
это мой код
// Module contains
////////////////////////////////////////// POintComponent.h
#include "CATBaseUnknown.h"
class CATCmdContainer;
class PointComponent: public CATBaseUnknown
{
CATDeclareClass;
public:
// Standard constructors and destructors for an implementation class
// -----------------------------------------------------------------
PointComponent ();
virtual ~PointComponent ();
void CreateCommands();
CATCmdContainer * CreateToolbars();
private:
-------------------------------------------------------------------
PointComponent (PointComponent &);
PointComponent& operator=(PointComponent&);
};
/////////////////////////////////////////PointComponent.cpp#include "PointComponent.h"// ApplicationFrame framework
#include "CATCreateWorkshop.h"#include "CATCommandHeader.h"
MacDeclareHeader(PointComponentHeader);
#include "CATIAfrGeneralWksAddin.h"
CATImplementClass(PointComponent,
Implementation,
CATBaseUnknown,
CATnull );
//TIE or TIEchain definitions
#include "TIE_CATIAfrGeneralWksAddin.h"TIE_CATIAfrGeneralWksAddin(PointComponent);//-----------------------------------------------------------------------------
// PointComponent : constructor
//-----------------------------------------------------------------------------
PointComponent::PointComponent():
CATBaseUnknown()
{
}
//-----------------------------------------------------------------------------
// PointComponent : destructor
//-----------------------------------------------------------------------------
PointComponent::~PointComponent()
{
}void PointComponent::CreateCommands ()
{
// Instantiates the command header for the command
new PointComponentHeader("CommandButtonCmd1", "PointComponent","Point", (void *)NULL);
}
//-----------------------------------------------------------------------------
// Implements CATIWorkbenchAddin::CreateToolbars
//-----------------------------------------------------------------------------
CATCmdContainer * PointComponent::CreateToolbars ()
{
NewAccess(CATCmdContainer,pToolbarContainer,PointComponentToolBar);
NewAccess(CATCmdStarter,pCommandStarter,PointComponentStarter);
SetAccessCommand(pCommandStarter,"CommandButtonCmd1");
SetAccessChild(pToolbarContainer,pCommandStarter);
AddToolbarView (pToolbarContainer,1,Top);return pToolbarContainer;
}//////////////////////////////////////Point.h
#include "CATCommand.h"
class Point
{
public:
Point();
~Point();
CATStatusChangeRC Point::Activate( CATCommand * iFromClient, CATNotification * iEvtDat)
};
//////////////////////////////////////////////Point.cpp#include "Point.h"
// Dialog framework
#include "CATDlgNotify.h"#include "CATFrmEditor.h"#include "CATCreateExternalObject.h"#include "CATDocument.h"#include "CATIContainer.h"#include "CATIGSMFactory.h"#include "CATIPrtFactory.h"#include "CATICkeParmFactory.h"#include "CATIGSMPoint.h"#include "CATISpecObject.h"#include "CATIGSMProceduralView.h"#include "CATApplicationFrame.h"#include "CATIContainerOfDocument.h"#include "CATIGSMPointCoord.h"#include "CATPoint.h"
CATCreateClass(Point);
Point::Point() :
CATCommand(NULL, "Point")
{
RequestStatusChange(CATCommandMsgRequestExclusiveMode);
}
//-------------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------------
Point::~Point()
{
}CATStatusChangeRC Point::Activate( CATCommand * iFromClient, CATNotification * iEvtDat)
{
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
if(pEditor == NULL)
{
printf("error getting the FRM editor");
}
CATDocument *pDoc = pEditor->GetDocument();
CATIContainerOfDocument_var spConODocs = pDoc;
CATIContainer* pSpecContainer = NULL;
HRESULT hr = spConODocs->GetSpecContainer(pSpecContainer);
if(spConODocs == NULL_var)
{
printf("error getting the container of documents");
}
CATIGSMFactory_var spGSMFactory = NULL_var;
CATIPrtFactory_var spPrtFactory = NULL_var;
CATICkeParmFactory_var spParmFactory = NULL_var;
spGSMFactory = pSpecContainer;
spPrtFactory = pSpecContainer;
spParmFactory = pSpecContainer;
double Coords[3];
Coords[0] = 0;
Coords[1] = 0;
Coords[2] = 0;
CATIGSMPoint_var spPoint1 = spGSMFactory->CreatePoint(Coords); //Creates a point
CATISpecObject_var spSpecPoint1 = spPoint1; //Casts the point as a CATISpecObject
spSpecPoint1->Update();
CATIGSMProceduralView_var spPntObj = spSpecPoint1;
spPntObj->InsertInProceduralView();
return (CATStatusChangeRCCompleted);
}
//////////////////////////////////////// imakefile.mk containsBUILT_OBJECT_TYPE=SHARED LIBRARY
# DO NOT EDIT :: THE CAA2 WIZARDS WILL ADD CODE HERE
WIZARD_LINK_MODULES = JS0GROUP \
JS0FM JS0GROUP ApplicationFrame CATAfrUUID
# END WIZARD EDITION ZONE
LINK_WITH = $(WIZARD_LINK_MODULES) \
CATApplicationFrame \
CATGitInterfaces \
CATObjectSpecsModeler \
CATDialogEngine \
CATMathematics \
CATObjectModelerBase \
CATPartInterfaces \
CATMecModInterfaces \//////////////////////////// identity.h file of framework containsAddPrereqComponent ("ApplicationFrame", Public);
AddPrereqComponent ("Dialog" , Public);
AddPrereqComponent ("System", Public);AddPrereqComponent ("GSMInterfaces", Public);
AddPrereqComponent ("ObjectModelerBase", Public);
AddPrereqComponent ("PartInterfaces", Public);
AddPrereqComponent ("KnowledgeInterfaces", Public);
AddPrereqComponent ("MecModInterfaces",Public);
AddPrereqComponent ("Visualization" , Public);
AddPrereqComponent ("GeometryVisualization" , Public);
AddPrereqComponent ("DialogEngine" , Public);
// INF Group - Base
AddPrereqComponent ("Mathematics" , Public);
AddPrereqComponent ("ObjectSpecsModeler" , Public);
AddPrereqComponent ("GeometricObjects" , Public);/////////////////////////////////CNext msgcatlog contains CATNI & Rsc files folder contains
/ // / // / // / / PointComponent.CATNI contains
pointToolBar.Title = "Toolbar 1";
//////////////////// PointComponentHeader.CATNIs contains
PointComponentHeader.CommandButtonCmd1.Title = "cmd1";
PointComponentHeader.CommandButtonCmd1.Help = "cmd1 long help text";
PointComponentHeader.CommandButtonCmd1.ShortHelp = "cmd1 info";
/////////////////////////////////// PointComponentHeader.CATRsc contains
PointComponentHeader.CommandButtonCmd1.Icon.Normal="Point_I";
Задача ещё не решена.
Других решений пока нет …