Python CAttachOp::AppendTextToProgram(CMachineState *pMachineState) { Python python; #ifdef OP_SKETCHES_AS_CHILDREN ReloadPointers(); // Make sure all the solids in m_solids are included as child objects. #endif python << COp::AppendTextToProgram(pMachineState); //write stl file std::list<HeeksObj*> solids; std::list<HeeksObj*> copies_to_delete; #ifdef OP_SKETCHES_AS_CHILDREN for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild()) { if (object->GetType() != SolidType && object->GetType() != StlSolidType) { continue; } #else for (std::list<int>::iterator It = m_solids.begin(); It != m_solids.end(); It++) { HeeksObj* object = heeksCAD->GetIDObject(SolidType, *It); #endif if (object != NULL) { if(1/* to do pMachineState->Fixture().GetMatrix() == gp_Trsf()*/) { solids.push_back(object); } } // End if - then } // End for wxStandardPaths standard_paths; wxFileName filepath( standard_paths.GetTempDir().c_str(), wxString::Format(_T("surface%d.stl"), number_for_stl_file).c_str() ); number_for_stl_file++; heeksCAD->SaveSTLFile(solids, filepath.GetFullPath(), 0.01); // We don't need the duplicate solids any more. Delete them. for (std::list<HeeksObj*>::iterator l_itSolid = copies_to_delete.begin(); l_itSolid != copies_to_delete.end(); l_itSolid++) { delete *l_itSolid; } // End for python << _T("nc.attach.units = ") << theApp.m_program->m_units << _T("\n"); python << _T("nc.attach.attach_begin()\n"); python << _T("nc.nc.creator.stl = ocl_funcs.STLSurfFromFile(") << PythonString(filepath.GetFullPath()) << _T(")\n"); python << _T("nc.nc.creator.minz = ") << m_min_z << _T("\n"); python << _T("nc.nc.creator.material_allowance = ") << m_material_allowance << _T("\n"); pMachineState->m_attached_to_surface = this; return(python); } // End AppendTextToProgram() method static void on_set_tolerance(double value, HeeksObj* object){((CAttachOp*)object)->m_tolerance = value;} static void on_set_min_z(double value, HeeksObj* object){((CAttachOp*)object)->m_min_z = value;} static void on_set_material_allowance(double value, HeeksObj* object){((CAttachOp*)object)->m_material_allowance = value;} void CAttachOp::GetProperties(std::list<Property *> *list) { #ifdef OP_SKETCHES_AS_CHILDREN AddSolidsProperties(list, this); #else AddSolidsProperties(list, m_solids); #endif list->push_back(new PropertyLength(_("tolerance"), m_tolerance, this, on_set_tolerance)); list->push_back(new PropertyLength(_("minimum z"), m_min_z, this, on_set_min_z)); list->push_back(new PropertyLength(_("material allowance"), m_material_allowance, this, on_set_material_allowance)); COp::GetProperties(list); }
Python CWaterline::AppendTextToProgram(CMachineState *pMachineState) { Python python; ReloadPointers(); // Make sure all the solids in m_solids are included as child objects. CTool *pTool = CTool::Find(m_tool_number); if(pTool == NULL) { return(python); } python << CDepthOp::AppendTextToProgram(pMachineState); // write the corner radius python << _T("corner_radius = float("); double cr = pTool->m_params.m_corner_radius - pTool->m_params.m_flat_radius; if(cr<0)cr = 0.0; python << ( cr / theApp.m_program->m_units ) << _T(")\n"); heeksCAD->CreateUndoPoint(); //write stl file std::list<HeeksObj*> solids; for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild()) { if (object->GetType() != SolidType && object->GetType() != StlSolidType) { continue; } if (object != NULL) { // Need to rotate a COPY of the solid by the fixture settings. HeeksObj* copy = object->MakeACopy(); if (copy != NULL) { double m[16]; // A different form of the transformation matrix. CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::YZ), m ); copy->ModifyByMatrix(m); CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XZ), m ); copy->ModifyByMatrix(m); CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XY), m ); copy->ModifyByMatrix(m); solids.push_back(copy); } // End if - then } // End if - then } // End for wxStandardPaths standard_paths; wxFileName filepath( standard_paths.GetTempDir().c_str(), wxString::Format(_T("waterline%d.stl"), number_for_stl_file).c_str() ); number_for_stl_file++; heeksCAD->SaveSTLFile(solids, filepath.GetFullPath(), m_params.m_tolerance); // We don't need the duplicate solids any more. Delete them. for (std::list<HeeksObj*>::iterator l_itSolid = solids.begin(); l_itSolid != solids.end(); l_itSolid++) { heeksCAD->Remove( *l_itSolid ); } // End for heeksCAD->Changed(); python << _T("ocl_funcs.waterline( filepath = ") << PythonString(filepath.GetFullPath()) << _T(", ") << _T("tool_diameter = ") << pTool->CuttingRadius() * 2.0 << _T(", ") << _T("corner_radius = ") << pTool->m_params.m_corner_radius / theApp.m_program->m_units << _T(", ") << _T("step_over = ") << m_params.m_step_over / theApp.m_program->m_units << _T(", ") << _T("mat_allowance = ") << m_params.m_material_allowance / theApp.m_program->m_units << _T(", ") << _T("clearance = clearance, ") << _T("rapid_safety_space = rapid_safety_space, ") << _T("start_depth = start_depth, ") << _T("step_down = step_down, ") << _T("final_depth = final_depth, ") << _T("units = ") << theApp.m_program->m_units << _T(", ") << _T("x0 = ") << m_params.m_box.m_x[0] / theApp.m_program->m_units << _T(", ") << _T("y0 = ") << m_params.m_box.m_x[1] / theApp.m_program->m_units << _T(", ") << _T("x1 = ") << m_params.m_box.m_x[3] / theApp.m_program->m_units << _T(", ") << _T("y1 = ") << m_params.m_box.m_x[4] / theApp.m_program->m_units << _T(", ") << _T("tolerance = ") << m_params.m_tolerance << _T(")\n"); return(python); }