Cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining feature layer

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hello everyone!

 

I got a bit stuck where I did not expect that. How do I obtain feature layer? I would like to be able to read it and change it.

5 REPLIES

Re: Obtaining feature layer

Siemens Phenom Siemens Phenom
Siemens Phenom

If you look at the Inheritance Hierarchy for the Feature class in the API docs, note that it does not inherit from the DisplayableObject class.  So it does not have display properties such as a Layer. (Although oddly enough, the Feature class does allow you to assign it a color.)

 

However most features have a related Body, and the Body class DOES have a Layer property.  So I would suggest trying to call GetEntities() on the Feature object you have, and I think that should give you the body (or bodies), and then you can ask (or set) the Layer.  The Layer property for the Body class says that it:

 

"Returns or sets the layer that the object is in.

(Inherited from DisplayableObject.)"

Re: Obtaining feature layer

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

This sounds strange. Each feature in a tree has its layer (with some minor exceptions like measurements). Does this mean that actually contained bodies have layer and not feature? Not all features contain bodies.

 

Re: Obtaining feature layer

Honored Contributor
Honored Contributor

"Does this mean that actually contained bodies have layer and not feature? Not all features contain bodies."

 

Yes; in this case the NX GUI gives us the wrong impression that the features have layers, when really it is the geometry that they create or modify. For instance, if you create a block then apply a blend to an edge, the part navigator will report the layer for the block and blend. The blend feature created a new face on the block, but individual body faces cannot be assigned to different layers, they all belong on the same layer as the parent body. You cannot use "move to layer" and select only the blend feature, the rest of the block body will come with it. Similarly, when you move the body from layer to layer, the block and blend features will update to show the new layer. So the features report the layer that the created/modified geometry is on; features do not have layers independent of some associated displayable object.

Re: Obtaining feature layer

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

This makes sense. Then what is the generic workflow if I want to obtain the layer and then possibly change it? Should I obtain feature and then its entities? Or what? Suggestions are welcome...

Re: Obtaining feature layer

Honored Contributor
Honored Contributor

Depends on what you are trying to do. Steve gave you one posssible workflow above. When moving things around to different layers, I usually work with the various object collections (.Bodies, .Curves, etc) and let the part navigator worry about updating itself when I'm done. Note that there are some composite objects which require special care, such as sketches and datum csys objects. For instance, a sketch feature represents a sketch object which manages various curve and constraint objects. You can move the curves and the sketch object to different layers, but (if I remember correctly) at the next part update, the curves will be automatically moved to the same layer as the parent sketch.