Cancel
Showing results for 
Search instead for 
Did you mean: 

Python equivalent syntax for uf5947 or TransformObjects

Pioneer
Pioneer

I'm not finding anything in the NXOpen Python (for NX10) documentation for NXOpen.UF.Trns that would show me the correct syntax for replicating the task of transforming objects done by  uf5947 (or TransformObjects in some GTAC examples).

 

Does anyone have an example of using this in Python?

4 REPLIES

Re: Python equivalent syntax for uf5947 or TransformObjects

Phenom
Phenom

You could use NXOpen.UF.Modl.TransformEntities

Suresh
Production: NX10.0.3 Developing: NX11.0.2.7, NX12.0.1
Development: C++, C# .Net, VB .Net, KF

Re: Python equivalent syntax for uf5947 or TransformObjects

Pioneer
Pioneer

Thank you for the response, but I'm not sure this will do what I want with the data that I have.  I will test it out and check if it is good enough.  It looks like there are significant differences between what is done by uf5947 and NXOpen.UF.Modl.TransformEntities aka UF_MODL_transform_entities:

  1. Modl.TransformEntities will move the parent entity items as well, I don't want this to happen, and there doesn't seem to be a way to turn it off?
  2. Modl.TransformEntities uses a 16 element matrix, I only have the 12 element matrix created by the UF_TRNS functions, and I'm not sure what those final 4 elements should be, or if they matter?
  3. uf5947 has a lot of status codes that would explain what went wrong if something went wrong

If it helps, the objects I'm trying to transform (actually move) are coordinate systems.

Re: Python equivalent syntax for uf5947 or TransformObjects

Pioneer
Pioneer

Attempting to do a "Move Object" manually on a coordinate system while recording a journal taught me a few things:

  1. This feature refuses to move a CSYS without moving the parents, as in it actually puts up an Alert message if you uncheck "Move Parents"
  2. If I do check "Move Parents" it moves the original coordinate system I based the new CSYS on, which is NOT the behavior I want
  3. It is using a "Move Object Builder" (see code snippet below) so that is something I can try experimenting with settings on an see if it does what I want with a non-standard set of options
moveObjectBuilder1 = workPart.BaseFeatures.CreateMoveObjectBuilder(NXOpen.Features.MoveObject.Null)

 

So I undid that feature while still recording the journal, and just went in to "Edit with Rollback" to see what it was using to move the existing CSYS around.  It is using an Xform to create a new CSYS to assign to the existing Datum CSYS.  Here are some lines extracted from that part of the journal:

datumCsysBuilder2 = workPart.Features.CreateDatumCsysBuilder(datumCsys2)
...
expression5.RightHandSide = "2"
...
scalar15 = workPart.Scalars.CreateScalarExpression(expression5, NXOpen.Scalar.DimensionalityType.Length, NXOpen.SmartObject.UpdateOption.WithinModeling)
...
offset3 = workPart.Offsets.CreateOffsetRectangular(scalar13, scalar14, scalar15, NXOpen.SmartObject.UpdateOption.WithinModeling)
...
xform4 = workPart.Xforms.CreateXform(cartesianCoordinateSystem2, NXOpen.Offset.Null, offset3, scalar16, scalar17, scalar18, 1, NXOpen.SmartObject.UpdateOption.WithinModeling, 1.0)
...
cartesianCoordinateSystem5 = workPart.CoordinateSystems.CreateCoordinateSystem(xform4, NXOpen.SmartObject.UpdateOption.WithinModeling)
...
datumCsysBuilder2.Csys = cartesianCoordinateSystem5
...
nXObject3 = datumCsysBuilder2.Commit()
datumCsysBuilder2.Destroy()

I might be able to use this round-about method and some of this syntax to get what I need for this script?  I'd still love to know if anyone has an answer for my original question.

 

Re: Python equivalent syntax for uf5947 or TransformObjects

Phenom
Phenom

I suspect you will get the same result (parent will move) with transform objects too if you are trying to move a datum csys which is based on another csys.   Try transform objects interactively.

 

Suresh
Production: NX10.0.3 Developing: NX11.0.2.7, NX12.0.1
Development: C++, C# .Net, VB .Net, KF