hexagon logo

Problem on adding BsicScan Points with C++

Hello,everyone,
I have learned a little about using C++ for PC_DMIS secondary development.
Here I am using BasicScan Object to add scan points,there were some errows happend caused that 0 points were generated.But I don't know why...
Here is a part of my code.Rolling eyes  ​Any comments are welcome...Wink

IApplication App;
IPartPrograms Ppms;
IPartProgram Ppm;
ICommands Cmds;
ICommand Cmd;

IBasicScan Bscn;
IPoint MS;
IPoint CP;
IPoint IT;


void CTest_01Dlg::OnAddCmd()
{
// declare variables
IBasicScan Bscn;
IPoint MS;
IPoint CP;
IPoint IT;

if(!ConnectPcdmis()) // Connect PC_DMIS,if failed , exit
{
return;
}
// Check if there is an open measuring program. If not, an error is reported
if(Ppms.GetCount() < 1)
{
AfxMessageBox("You need to open at least one measurement program to do this~",MB_ICONWARN ING);
ReleasePcdmis();
return;
}
Ppm = App.GetActivePartProgram(); // Connect to the current PC_DMIS measurement program

// Test section, add command
Cmds = Ppm.GetCommands(); // Connect to the set of commands for this measure

// Cmds.AddCmdOfName(214,TRUE,"demo.PRG"); // add command 214
// Cmds.Add(214,TRUE);

/*
CString temp;
temp.Format(_T("%d"),Cmds.GetCount());
AfxMessageBox(temp);
*/

Cmd = Cmds.AddCmdOfName(214,FALSE,"demo.PRG");

Bscn = Cmd.GetBasicScanCommand();

Bscn.SetMethod(100125);

Bscn.SetMethodParams(2, 1, 1, 23.5,180,-5,0);

MS.XYZ(-30.75,111,13); // MethodStart(-30.75,111,13)
CP.IJK(0,0,-1); // CutPlane(0,0,-1)
IT.IJK(1,0,0); // InitTouch(1,0,0)

Bscn.SetMethodStart(MS);
Bscn.SetMethodCutPlane(CP);
Bscn.SetMethodInitTouch(IT);

Bscn.GenerateScan();

Bscn.CreateBasicScan();


}


  • I finally solved the problem myself,Now,I put the tips.May it could help someoneRolling eyes

    Cmd = Cmds.AddCmdOfName(214,TRUE,"demo.PRG");
    
    Bscn = Cmd.GetBasicScanCommand();
    
    Bscn.SetMethod(100125);
    
    Bscn.SetFilter(200010);
    Bscn.SetNominalMode(400001);
    Bscn.SetHitType(700010);
    Bscn.SetOperationMode(500022);
    
    
    MS.CreateDispatch("PCDLRN.PointData");
    CP.CreateDispatch("PCDLRN.PointData");
    IT.CreateDispatch("PCDLRN.PointData");
    
    
    MS.XYZ(8.085,3.4646,-0.8037); // MethodStart
    CP.IJK(0.5,0,0.8660254); // MethodCutPlane
    IT.IJK(-0.8660254,0,0.5); // MethodInitTouch
    
    
    Bscn.SetMethodStart(MS);
    Bscn.SetMethodCutPlane(CP);
    Bscn.SetMethodInitTouch(IT);
    
    Bscn.SetMethodParams(0, 1, 1, 1.4173,360,0,0);
    
    Bscn.SetFilterParams(0, 0, 0.1, 0.1, 0, 360);
    
    Bscn.GenerateScan();
    
    Bscn.CreateBasicScan();
    
    Cmd.ReDraw();]



    And there was another step after all above program executed, needing to point to the feature you added,and then click F9(/Fn + F9) --> conventional --> Display the contact point -->Apply.Finally you will find the contact pint number changed from 0 to what you want in Editwindow.
    .