Cancel
Showing results for 
Search instead for 
Did you mean: 

Question about layer operation in NXOpen C++

Pioneer
Pioneer

Hello,

  I want to find some object in a work part and change its layer. I use the API of NXOpen C++. 

  When I want to find DatumCsys, I use the following code to find them and move them to another layer.But it tells me DatumCsys is not a displayableObject, so  i cannot use the MoveDisplayableObjects() function. So here's the question, what can i do to move the DatumCsys object to another layer?

 

screenshot.PNG

24 REPLIES

Re: Question about layer operation in NXOpen C++

Esteemed Contributor
Esteemed Contributor

Did you try to record a journal of the manual process to see how the NX developers would do it?

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: NX12.0

How to Get the Most from Your Signature in the Community

Re: Question about layer operation in NXOpen C++

Pioneer
Pioneer

Yes, I do. Here is the journal. It use journal identifier to find obects. And it find the CartesianCoordinateSystem object in datumPlane  to do the layer operation. However, how can i find these objects if I don't know the journal identifier?

screenshot1.PNG

 

Re: Question about layer operation in NXOpen C++

Esteemed Contributor
Esteemed Contributor

The datum CSYS feature consists of multiple displayable objects, so you need to move all of them.

  1. the origin point
  2. the coordinate system
  3. three datum planes
  4. three datum axis

I think it is the GetEntities method that allows you to get the objects contained in the feature.

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: NX12.0

How to Get the Most from Your Signature in the Community

Re: Question about layer operation in NXOpen C++

Pioneer
Pioneer
I don't really understand what GetEntities method is, I'd appreciate it so much if you can explain some more details for me.

Re: Question about layer operation in NXOpen C++

Esteemed Contributor
Esteemed Contributor

I was just checking the NXOpen API reference, since I am mostly automating NX CAM, so I am not fluent in handling NX CAD objects.

If you don't have the NXOpen API reference and programmers guide installed, you are lost.

Also make sure to take a good read of the SNAP quick start guide, since there are many things explained of the things behind the curtain.

In addition there is a section in the programmers guide to help you getting rid of the FindObject methods, which in my opinion are just there to confuse newbies.

 

GetEntities returns an array of NXObjects, so you would cast those individually to displayable objects and move the resulting objects all together to the new layer.

This is just my understanding by reading your journal.

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: NX12.0

How to Get the Most from Your Signature in the Community

Re: Question about layer operation in NXOpen C++

Pioneer
Pioneer
Thank you very much for you reply and suggestions, I'll read the guidance and the API reference again and try this method.

Re: Question about layer operation in NXOpen C++

Legend
Legend

Below is the code in C#. 

 

static void setDatumCsysLayer(NXOpen.Features.DatumCsys theDatumCsys, int theLayer)
    {
        foreach (DisplayableObject theDO in theDatumCsys.GetEntities())
        {
            theDO.Layer = theLayer;
        }
    }

Re: Question about layer operation in NXOpen C++

Pioneer
Pioneer
Thank you. I nearly understand what GetEntities is, but now i'm using NXOpen C++, and i'm wondering whether this method can be done in C++.

Re: Question about layer operation in NXOpen C++

Esteemed Contributor
Esteemed Contributor

C++, Java, C# and VB.NET share all the same methods for each object, so this must be available too.

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: NX12.0

How to Get the Most from Your Signature in the Community