I need to create a large number of unassociated lines in NX. The below code runs without problem but the lines are never displayed.
It feels like I'm missing some minor, trival thing. Any ideas?
NXOpen::Session *theSession = NXOpen::Session::GetSession(); NXOpen::Part *workPart(theSession->Parts()->Work()); NXOpen::Part *displayPart(theSession->Parts()->Display()); Vector3d direction = Vector3d(end.X - start.X, end.Y - start.Y, end.Z - start.Z); double length = sqrt(direction.X*direction.X + direction.Y*direction.Y + direction.Z*direction.Z); NXOpen::LineCollection* lines = workPart->Lines(); NXOpen::CurveCollection * curveColection = workPart->Curves(); NXOpen::Point* startPnt = workPart->Points()->CreatePoint(start); NXOpen::Point* endPnt = workPart->Points()->CreatePoint(end); NXOpen::Line* line =curveColection->CreateLine(startPnt, endPnt); line->RedisplayObject();
If I journal line creation it calls CreateAssociativeLineBuilder. My assumption is that that would be slower than that what I did above but at least it works.
Solved! Go to Solution.
The line that you have created is a "SmartObject". You will need to use the SetVisibility method to make it visible (it is created as invisible by default).
Is your intention to make a 'dumb' curve? If so, you will want to use the RemoveParameters method after line creation. If you do not, you will end up with a line that is neither a dumb curve nor is it an associative curve feature. In your case, the line will be associative to the points; but the user will have no way of editing the resulting line.
A few links below for more info:
As is often the case in NX, there may be more than one possible solution.
If you really just need "dumb" curves, try UF_CURVE_create_line(). The created line will not be invisible, and you will not have to add it to the display.
Sigh... it never occured to me it would be off by default. The following did the trick.
hi Mark! Did you generate these lines using C++ ? I am curious to know as I am trying to generate curves (in form of the curve points connected via lines) using C++ programming and executing it in NX (in form of .dll).