silumin
Aerospace
- Feb 16, 2012
- 1
Hello,
I try to create simple extrusion programm based on journal recordings (C++). I recorded the following sequence (NX6): create sketch -> draw circle -> finish sketch -> create extrusion. I compiled that code using NX6 Open Wizard (Visual 2010). I executed it and it stopped after finishing the sketch. I also complied the same code using NX8 Open Wizard and I tried it under NX8 environment and it works just fine (can't execute this working .dll under NX6). My question is: how to modify this code so it can work under NX6? I also tried to modify sketch and circle names but it don't want to work either. I would appreciate any help in this issue.
I try to create simple extrusion programm based on journal recordings (C++). I recorded the following sequence (NX6): create sketch -> draw circle -> finish sketch -> create extrusion. I compiled that code using NX6 Open Wizard (Visual 2010). I executed it and it stopped after finishing the sketch. I also complied the same code using NX8 Open Wizard and I tried it under NX8 environment and it works just fine (can't execute this working .dll under NX6). My question is: how to modify this code so it can work under NX6? I also tried to modify sketch and circle names but it don't want to work either. I would appreciate any help in this issue.
Code:
#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Arc.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/Curve.hxx>
#include <NXOpen/CurveCollection.hxx>
#include <NXOpen/CurveDumbRule.hxx>
#include <NXOpen/DatumAxis.hxx>
#include <NXOpen/DatumPlane.hxx>
#include <NXOpen/Direction.hxx>
#include <NXOpen/DirectionCollection.hxx>
#include <NXOpen/DisplayableObject.hxx>
#include <NXOpen/Expression.hxx>
#include <NXOpen/Facet_FacetedBodyCollection.hxx>
#include <NXOpen/Features_ExtrudeBuilder.hxx>
#include <NXOpen/Features_Feature.hxx>
#include <NXOpen/Features_FeatureBuilder.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/GeometricUtilities_BooleanOperation.hxx>
#include <NXOpen/GeometricUtilities_Extend.hxx>
#include <NXOpen/GeometricUtilities_FeatureOffset.hxx>
#include <NXOpen/GeometricUtilities_FeatureOptions.hxx>
#include <NXOpen/GeometricUtilities_Limits.hxx>
#include <NXOpen/GeometricUtilities_MultiDraft.hxx>
#include <NXOpen/GeometricUtilities_OnPathDimensionBuilder.hxx>
#include <NXOpen/GeometricUtilities_SimpleDraft.hxx>
#include <NXOpen/INXObject.hxx>
#include <NXOpen/NXMatrix.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Plane.hxx>
#include <NXOpen/Point.hxx>
#include <NXOpen/ScCollector.hxx>
#include <NXOpen/ScRuleFactory.hxx>
#include <NXOpen/Section.hxx>
#include <NXOpen/SectionCollection.hxx>
#include <NXOpen/SelectIReferenceAxis.hxx>
#include <NXOpen/SelectISurface.hxx>
#include <NXOpen/SelectObject.hxx>
#include <NXOpen/SelectionIntentRule.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Sketch.hxx>
#include <NXOpen/SketchAlongPathBuilder.hxx>
#include <NXOpen/SketchCollection.hxx>
#include <NXOpen/SketchInPlaceBuilder.hxx>
#include <NXOpen/TaggedObject.hxx>
#include <NXOpen/Unit.hxx>
#include <NXOpen/Update.hxx>
using namespace NXOpen;
extern "C" DllExport int ufusr_ask_unload()
{
return (int)Session::LibraryUnloadOptionImmediately;
}
extern "C" DllExport void ufusr(char *param, int *retcod, int param_len)
{
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
// ----------------------------------------------
// Menu: Insert->Sketch...
// ----------------------------------------------
theSession->BeginTaskEnvironment();
Sketch *nullSketch(NULL);
SketchInPlaceBuilder *sketchInPlaceBuilder1;
sketchInPlaceBuilder1 = workPart->Sketches()->CreateSketchInPlaceBuilder(nullSketch);
Section *section1;
section1 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.5);
Section *section2;
section2 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.5);
NXObject *nXObject1;
nXObject1 = sketchInPlaceBuilder1->Commit();
Sketch *sketch1(dynamic_cast<Sketch *>(nXObject1));
Features::Feature *feature1;
feature1 = sketch1->Feature();
sketch1->Activate(Sketch::ViewReorientTrue);
sketchInPlaceBuilder1->Destroy();
section2->Destroy();
section1->Destroy();
theSession->ActiveSketch()->SetName("SKETCH_000");
workPart->FacetedBodies()->DeleteTemporaryFacesAndEdges();
// ----------------------------------------------
// Dialog Begin Profile
// ----------------------------------------------
// ----------------------------------------------
// Menu: Insert->Curve->Circle...
// ----------------------------------------------
NXMatrix *nXMatrix1;
nXMatrix1 = theSession->ActiveSketch()->Orientation();
Point3d center1(1.10478224478649, 1.15463443670529, 0.0);
Arc *arc1;
arc1 = workPart->Curves()->CreateArc(center1, nXMatrix1, 0.554408927494222, 0.0, ( 360.0 * DEGRA ));
theSession->ActiveSketch()->AddGeometry(arc1, Sketch::InferConstraintsOptionInferNoConstraints);
// ----------------------------------------------
// Dialog Begin Circle
// ----------------------------------------------
// ----------------------------------------------
// Menu: Sketch->Finish Sketch
// ----------------------------------------------
theSession->ActiveSketch()->Deactivate(Sketch::ViewReorientTrue, Sketch::UpdateLevelModel);
theSession->DeleteUndoMarksSetInTaskEnvironment();
theSession->EndTaskEnvironment();
// ----------------------------------------------
// Menu: Insert->Design Feature->Extrude...
// ----------------------------------------------
Section *section3;
section3 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.5);
Features::Feature *nullFeatures_Feature(NULL);
Features::ExtrudeBuilder *extrudeBuilder1;
extrudeBuilder1 = workPart->Features()->CreateExtrudeBuilder(nullFeatures_Feature);
extrudeBuilder1->SetSection(section3);
extrudeBuilder1->SetDistanceTolerance(0.001);
section3->SetDistanceTolerance(0.001);
section3->SetChainingTolerance(0.00095);
std::vector<Curve *> curves1(1);
curves1[0] = arc1;
CurveDumbRule *curveDumbRule1;
curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleCurveDumb(curves1);
section3->AllowSelfIntersection(false);
std::vector<SelectionIntentRule *> rules1(1);
rules1[0] = curveDumbRule1;
NXObject *nullNXObject(NULL);
Point3d helpPoint1(0.73818233373921, 1.55872917736053, 0.0);
section3->AddToSection(rules1, arc1, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
Direction *direction1;
direction1 = workPart->Directions()->CreateDirection(sketch1, SenseForward, SmartObject::UpdateOptionWithinModeling);
extrudeBuilder1->SetDirection(direction1);
extrudeBuilder1->Offset()->EndOffset()->SetRightHandSide("1.1");
extrudeBuilder1->SetParentFeatureInternal(false);
Features::Feature *feature2;
feature2 = extrudeBuilder1->CommitFeature();
extrudeBuilder1->Destroy();
workPart->FacetedBodies()->DeleteTemporaryFacesAndEdges();
// ----------------------------------------------
// Menu: Tools->Journal->Stop Recording
// ----------------------------------------------
}