Cancel
Showing results for 
Search instead for 
Did you mean: 

Editing an existing datum plane

Valued Contributor
Valued Contributor

HI,

 

I have created a datum plane using  UF_MODL_create_point_dirr_dplane and am later on trying to edit this datum plane using UF_MODL_edit_datum_point but am getting a memory access vialoation error. Has anybody tried suing this API before? Below is the code snippet for reference

 

DatumPlane CreatePointDirDatumPlane(Point3d planeOrigin, int count)
{
if (count == 0)
{
Point originPoint = Session.GetSession().Parts.Work.Points.CreatePoint(planeOrigin);
Direction direction1 = Session.GetSession().Parts.Work.Directions.CreateDirection(new Point3d(0.0, 0.0, 0.0), new Vector3d(1.0, 0.0, 0.0), SmartObject.UpdateOption.WithinModeling);

UFSession.GetUFSession().Modl.CreatePointDirrDplane(originPoint.Tag, direction1.Tag, out Tag dPlane);

thePointDirPlane = (DatumPlane)NXObjectManager.Get(dPlane);

return thePointDirPlane;
}

else
{
DatumPlaneFeature dPlaneFea = (DatumPlaneFeature)thePointDirPlane.Feature;

Point originPoint = Session.GetSession().Parts.Work.Points.CreatePoint(planeOrigin);

UFSession.GetUFSession().Modl.EditDatumPoint(dPlaneFea.Tag, originPoint.Tag);

return thePointDirPlane;
}
}

1 REPLY 1

Re: Editing an existing datum plane

Gears Phenom Gears Phenom
Gears Phenom

You don't show where 'thePointDirPlane' is defined/created when parameter 'count' is not zero.

The documentation of 'EditDatumPoint' (UF_MODL_edit_datum_point) states:

The feature should have been created using UF_MODL_create_point_dirr_daxis() or
UF_MODL_create_point_dirr_dplane(). If a smart object is used to specify the
new point, its update option should be UF_SO_update_within_modeling.

Was 'thePointDirPlane' created using either of these functions?

The alternative (and preferred method) would be to modify the point and direction using the DtaumPlaneBuilder. In pseudo code this would look something like this:

 

DatumPlaneBuilder = CreateDatumPlaneBuilder(thePointDirPlane)
DatumPlaneBuilder.SetPointAndDirection(point, direction)
SatumPlaneBuilder.Commit()

Note that SetPointAndDirection() takes a Point object and a Direction object, both of which you will have to construct. Pseudo code again:

Point = WorkPart.Points.CreatePoint(originPoint)
Vector = thePointDirPlane.Vector()
Direction = WorkPart.Directions.CreateDirection(originPoint, Vector, UpdateOption.WITHIN_MODELING)

 

 

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]