Showing results for 
Search instead for 
Do you mean 
Reply

CreateXformByDynamicOffset Function NXOpen C#

Hey guys i need some Help with this Function : CreateXformByDynamicOffset.

i want to move a Datum from one Location to another.

i have the Start Position of the Origin and the objective Position.

 

The Function needs a Transformation Matrix and an Originoffset (vector3d)

 

My Question are:

 

1. where do i get this Transformation Matrix and why do i need this ?

 

2. what is my Origin Offset ? Is it the DistanceVector or the vector to the Objective location ?

 

Hope that sb can explain me.

 

Thanks !

7 REPLIES

Re: CreateXformByDynamicOffset Function NXOpen C#

What type of datum are you moving? A datum csys?

(I assume this is related to your other question:

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization/Move-Csys-C-NXOpen/m-p/...)

 

If you are moving a datum csys, is it associated to other geometry, or is it independent of other geometry? If it is associated to other geometry and you want to keep the associativity, it will require more code to maintain the associativity. Moving an independent datum csys should be considerably easier.

Re: CreateXformByDynamicOffset Function NXOpen C#

Jes i'm moving a Datum csys and it is associated to other geometry :/
i created a xform with CreateXform and created a new coordinate System with this xform. The Datum Csys were moved wright but all associations were deleted. Maybe there is a function to replace the xform of an existing coordinate System. I tried to do that but i always get the message that the xform is only for read.

Re: CreateXformByDynamicOffset Function NXOpen C#

To edit the existing xform of a datum csys, you have to go one level deeper and modify the underlying properties of the xform.

 

So you would change csys.xform.orientation.Xx, etc. and csys.xform.origin.x, etc.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: CreateXformByDynamicOffset Function NXOpen C#

their is no xform property in the class of the Csys. (Data Type : CartesianCoordinateSystem, i tried also Data Type CoordinateSystem)

i tried:
csys.orientation.owningPart.xforms..(only Tag and NextSink)
or
csys.owningPart.xforms..(only Tag and NextSink)

Re: CreateXformByDynamicOffset Function NXOpen C#

i also tried this :
csys.Origin = new Point3d(xform1.Origin.X,xform1.Origin.X,xform1.Origin.X);

but it can't perform this Action on a smart object :/

Re: CreateXformByDynamicOffset Function NXOpen C#

Here is what I would do:

  1. record a journal of the task I have to put into code
  2. use the created journal as a blueprint for my code
  3. generalize the journal by replacing all FindObject methods with object selections or similar

I think else we are going in circles here.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: CreateXformByDynamicOffset Function NXOpen C#

using System;
using NXOpen;

public class NXJournal
{
public static void Main(string[] args)
{
NXOpen.Session theSession = NXOpen.Session.GetSession();
NXOpen.Part workPart = theSession.Parts.Work;
NXOpen.Part displayPart = theSession.Parts.Display;
NXOpen.Features.DatumCsys datumCsys1 = (NXOpen.Features.DatumCsys) workPart.Features.FindObject("DATUM_CSYS(1000)");
workPart.Features.SetEditWithRollbackFeature(datumCsys1);

datumCsys1.MakeCurrentFeature();

NXOpen.Features.DatumCsysBuilder datumCsysBuilder1;
datumCsysBuilder1 = workPart.Features.CreateDatumCsysBuilder(datumCsys1);

NXOpen.Unit unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
NXOpen.Expression expression1;
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Unit unit2 = (NXOpen.Unit)workPart.UnitCollection.FindObject("Degrees");
NXOpen.Expression expression2;
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2);

NXOpen.Expression expression3;
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression4;
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2);

NXOpen.Expression expression5;
expression5 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

NXOpen.Expression expression6;
expression6 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2);

theSession.SetUndoMarkName(markId3, "Datum CSYS Dialog");

// ----------------------------------------------
// Dialog Begin Datum CSYS
// ----------------------------------------------
NXOpen.Features.DatumCsys datumCsys2 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject("DATUM_CSYS(998)");
NXOpen.CartesianCoordinateSystem cartesianCoordinateSystem1 = (NXOpen.CartesianCoordinateSystem)datumCsys2.FindObject("CSYSTEM 1");
NXOpen.Vector3d originOffset1 = new NXOpen.Vector3d(9.07607322631065e-015, 150.0, 4.88498130835069e-014);
NXOpen.Matrix3x3 trasformMatrix1 = new NXOpen.Matrix3x3();
trasformMatrix1.Xx = 1.0;
trasformMatrix1.Xy = -9.54097911787244e-018;
trasformMatrix1.Xz = 0.0;
trasformMatrix1.Yx = -9.54097911787244e-018;
trasformMatrix1.Yy = 1.0;
trasformMatrix1.Yz = 0.0;
trasformMatrix1.Zx = 0.0;
trasformMatrix1.Zy = 0.0;
trasformMatrix1.Zz = 1.0;
NXOpen.Xform xform1;
xform1 = workPart.Xforms.CreateXformByDynamicOffset(cartesianCoordinateSystem1, originOffset1, trasformMatrix1, NXOpen.SmartObject.UpdateOption.WithinModeling, 1.0);

NXOpen.CartesianCoordinateSystem cartesianCoordinateSystem2;
cartesianCoordinateSystem2 = workPart.CoordinateSystems.CreateCoordinateSystem(xform1, NXOpen.SmartObject.UpdateOption.WithinModeling);

datumCsysBuilder1.Csys = cartesianCoordinateSystem2;

datumCsysBuilder1.DisplayScaleFactor = 1.0;

NXOpen.NXObject nXObject1;
nXObject1 = datumCsysBuilder1.Commit();

datumCsysBuilder1.Destroy();

theSession.Preferences.Modeling.UpdatePending = false;