Cancel
Showing results for 
Search instead for 
Did you mean: 

Attributes inherited from another object

Gears Phenom Gears Phenom
Gears Phenom

I'm having problems with a couple of objects that I'm creating using my code. The scenario is:

  • Using a Blockdialog a user can create a series of DatumCoordinateSystems (DCSYS), these get attributes assigned according to users inputs.
  • Some of the DCSYS objects are offset from another one of the DCSYS.
  • Everything is fine until the user decides to modify something and the value of one of the attributes changes. If the DCSYS that was modifed is used as the original to offset another DCSYS, at this point the offset DCSYS inherits all of the attributes from the other DCSYS.

Is this expected? I didn't think so.  If I manually create 2 DCSYS with the second offset from the other and add attributes to them I can't reproduce this.

In the documentation the only reference I can see to inherited attributes is in an assembly situation, which this isn't.

The problem I have is that later when I read the attributes I can see the inherited ones which breaks some logic in the code because unexpected attributes exist.

Example part is attached, and a video of it happening below.

(view in My Videos)

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]
7 REPLIES 7

Re: Attributes inherited from another object

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Strange.

Can you share the portion of code that creates the offset csys?

Re: Attributes inherited from another object

Gears Phenom Gears Phenom
Gears Phenom

So here's the code (Java). Note that the actual code is inside a library of common functionality, so I've had to pick out the bits used to create an offset DatumCsys and hack them into a single list of code.

Csys csysToOffsetFrom;	// This Csys has been selected from another DatumCsys
Double xValue;		// User supplied offset and rotation values..
Double yValue;
Double zValue;
Double xAngle;
Double yAngle;
Double zAngle;
Part workPart;		// The work part, no assemblies involved

DatumCsysBuilder dcsysBuilder = workPart.features().createDatumCsysBuilder(null);
Unit mm = workPart.unitCollection().findObject("MilliMeter");
Unit deg = workPart.unitCollection().findObject("Degrees");

Expression xExp = workPart.expressions().createSystemExpressionWithUnits(Double.toString(xValue), mm);
Expression yExp = workPart.expressions().createSystemExpressionWithUnits(Double.toString(yValue), mm);
Expression zExp = workPart.expressions().createSystemExpressionWithUnits(Double.toString(zValue), mm);

Expression xRot = workPart.expressions().createSystemExpressionWithUnits(Double.toString(xAngle), deg);
Expression yRot = workPart.expressions().createSystemExpressionWithUnits(Double.toString(yAngle), deg);
Expression zRot = workPart.expressions().createSystemExpressionWithUnits(Double.toString(zAngle), deg);

Scalar xOffsetScalar = workPart.scalars().createScalarExpression(xExp, DimensionalityType.LENGTH, UpdateOption.WITHIN_MODELING);
Scalar yOffsetScalar = workPart.scalars().createScalarExpression(yExp, DimensionalityType.LENGTH, UpdateOption.WITHIN_MODELING);
Scalar zOffsetScalar = workPart.scalars().createScalarExpression(zExp, DimensionalityType.LENGTH, UpdateOption.WITHIN_MODELING);

Scalar xRotationScalar = workPart.scalars().createScalarExpression(xRot, DimensionalityType.ANGLE, UpdateOption.WITHIN_MODELING);
Scalar yRotationScalar = workPart.scalars().createScalarExpression(yRot, DimensionalityType.ANGLE, UpdateOption.WITHIN_MODELING);
Scalar zRotationScalar = workPart.scalars().createScalarExpression(zRot, DimensionalityType.ANGLE, UpdateOption.WITHIN_MODELING);

Offset offset = workPart.offsets().createOffsetRectangular(xOffsetScalar, yOffsetScalar, zOffsetScalar, UpdateOption.WITHIN_MODELING);
Xform xform = workPart.xforms().createXform(csysToOffsetFrom, null, offset, xRotationScalar, yRotationScalar, zRotationScalar, rotateFirst, UpdateOption.WITHIN_MODELING, 1.0);
Csys csys = workPart.csys().createCoordinateSystem(xform, UpdateOption.WITHIN_MODELING);
dcsysBuilder.setCsys(this.csys);
dcsysBuilder.setDisplayScaleFactor(1.0);
DatumCsys dcsys = (DatumCsys) dcsysBuilder.commit();
dcsysBuilder.destroy();
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]

Re: Attributes inherited from another object

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

I've duplicated your issue in interactive NX (I'm running NX 10, if I have time later I'll install NX 12 and re-test). The steps I took were:

  • start a new file from the modeling template (datum csys exists at absolute 0)
  • right click the datum csys and choose properties, change the option to "object" instead of "feature", create a new string attribute with some value
  • create an associative offset datum csys from the first
  • check properties of new datum csys (object), it has no attributes
  • edit the properties of the source datum csys, edit the value of the previously created attribute
  • check properties of offset csys (object), it now has a matching attribute with the updated value

The result was unexpected (to me, at least). I'd suggest calling GTAC; perhaps it is "working as designed", if so, I can't imagine why it was designed that way.

Re: Attributes inherited from another object

Gears Phenom Gears Phenom
Gears Phenom

Hi @cowski1 

Thanks for looking into this.

In NX12 I could not reproduce this using the steps you outlined (I'd already tried this actually, but did it a bit more methodically this time). The only difference is that none of our template parts have a Datum Csys already in, so after creating a new part I had to create a Datum Csys at absolute.

If you are going to try it in NX12, I'll hold off reporting to GTAC until I know if you can reproduce it or not.

I've now implemented in our framework the option to check if an attribute is inherited or not and to check if an attribute overrides an inherited one. This got my code working again, but I still feel like NX is not working correctly.

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]

Re: Attributes inherited from another object

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@Inch ,

I get the weird attribute behavior in NX 10.0.3.5, but I cannot duplicate it in NX 11.0.2.7 or NX 12.0.2.9.

Perhaps it is a bug from NX 10 that is re-appearing when you use the API functions? I don't know.

Re: Attributes inherited from another object

Gears Phenom Gears Phenom
Gears Phenom

I just created an IR for this: 9518958.

If anyone is interested in trying this, follow these steps:

  1. Create a new part
  2. Run the attached C# journal
  3. Manually add an attribute to the Csys of the first Datum Csys created (i.e. MB3 the Datum Csys feature and choose properties, go to the Attributes tab and choose "Apply to" Object).
  4. MB3 the second Datum Csys and look at the attributes for that, again use the "Apply to" Object view. The attribute added to the first Csys has been inherited.
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]

Re: Attributes inherited from another object

Gears Phenom Gears Phenom
Gears Phenom

Solution from GTAC was to create an intermediate CSYS offset from the original by 0,0,0, then create the actual offset CSYS from the intermediate one. See the attached journal.

As I said in my reply to GTAC, I'm still not sure if this is a bug in NX or how it is supposed to work. However, this is the solution so far.

 

Edit: I've just had this confirmed that it is NOT a bug and creating the intermediate CSYS is the correct method

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]