Cancel
Showing results for 
Search instead for 
Did you mean: 

Getting correct builder from object?

Pioneer
Pioneer

Hello all,

 

I've searched the forums with no luck on this.

 

I have a list of NXOpen.Cam.FeatureGeometry objects and I want to systematically edit them. However, it seems ambiguious which builder to use. For example, there seems to be no distinguishment between a "workpiece" type and a "Mill area" type, so if I want to modify these existing objects I can't tell from just the NXOpen.Cam.FeatureGeometry object which builder to create.

 

Is there a programatic way to idenfity the correct builder for an object? 

19 REPLIES

Re: Getting correct builder from object?

Siemens Phenom Siemens Phenom
Siemens Phenom

Record a journal, and see which builders the recorded code uses.

山田
yamada

Re: Getting correct builder from object?

Pioneer
Pioneer

Hi @Yamada, thanks for your reply.

 

To be more clear about my question, I know the various classes of machining geomety builders. However, given a list of objects from the geometrycollection, there does not appear to be a way to determine 

 

given a list of objects filtered by the FeatureGeometry collection:

feature_geometry = [x for x in self.workPart.CAMSetup.CAMGroupCollection if type(x) == NXOpen_CAM.FeatureGeometry]

How can I tell which objects are, for example, workpiece objects vs mill area objects? There does not appear to be an attribute or collection that segregates objects into these types. 

Re: Getting correct builder from object?

Phenom
Phenom

Below is a snippet from solution center in C++.  Hope this helps.

 

Clipboard01.jpg

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

Re: Getting correct builder from object?

Pioneer
Pioneer

Ok, I still don't think my question is clear enough.

 

Below is the debugger output showing a list of 3 geometry features, a mill boundary (MILL_BND), a workpiece (WORKPIECE) and a mill area (MILL_AREA)

2018-11-27_18-32-55.pngAs you can see, there is no exposed attribute that differentiates these 3 different types of machining feature geometry other than the name or journal identifier string.

 

I want to be able to programatically access these objects and select the correct builder. However, to do that I need to know what type of machining geometry it is so I can invoke the right builder to modify it.

 

Is there some higher-level access method I am missing or don't know about? Some parent object property?

 

FWIW I'm coding in python. 

Re: Getting correct builder from object?

Siemens Phenom Siemens Phenom
Siemens Phenom

I'm not a machining expert, but it seems like NXOpen.UF.UFObj.AskTypeAndSubtype() should work. A different subtype should be returned for each object type. These subtypes are typically defined in %UGII_BASE_DIR%\UGOPEN\uf_object_types.h:

 

#define UF_machining_geometry_grp_type          105       /* Machining geometry group */
#define    UF_mill_geom_featr_subtype                 10  /* Milling geometry workpiece */
#define    UF_mill_bnd_featr_subtype                  20  /* Boundary geometry */
#define    UF_mill_orient_subtype                     30  /* Mill orientation */
#define    UF_mill_volume_featr_subtype               35  /* Milling feature volume */
#define    UF_turn_geom_subtype                       40  /* Turning geometry */
#define    UF_turn_bnd_subtype                        50  /* Turning boundary */
#define    UF_turn_orient_subtype                     60  /* Turning orientation */
#define    UF_turn_featr_subtype                      65  /* Turning feature */
#define    UF_turn_avoidance_subtype                  67  /* Turning avoidance */
#define    UF_mach_wedm_external_group_subtype        70  /* Wire EDM external */
#define    UF_mach_wedm_internal_group_subtype        80  /* Wire EDM internal */
#define    UF_mach_wedm_open_group_subtype            90  /* Wire EDM open  */
#define    UF_mach_wedm_nocore_group_subtype         100  /* Wire EDM nocore */ 
#define    UF_mach_wedm_feature_group_subtype        110  /* Wire EDM feature */
#define    UF_wedm_orient_subtype                    120  /* Wire EDM orientation */
#define    UF_drill_geom_featr_subtype               130  /* Drill geometry */
#define    UF_ncfeatr_udf_subtype                    140  /* Unused */
#define    UF_ncfeatr_uda_subtype                    150  /* Unused */
#define    UF_fbm_geom_subtype                       160  /* Feature based geometry */
#define    UF_mill_text_featr_subtype                170  /* Text geometry */
#define    UF_blade_featr_subtype                    180  /* Blade geometry */
#define    UF_cylindrical_geometry_subtype           190  /* Hole geometry */
#define    UF_feature_container_subtype              200

Re: Getting correct builder from object?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

There is a workpiece collection that you can access through the part's .ToolingManager property. A quick search didn't turn up anything similar for the other objects mentioned. When dealing with various objects, you can use python's type method to determine the object type. When debugging, I'll often output str(type(myobj)) to the listing window (or other output) to see what I'm dealing with.

Re: Getting correct builder from object?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@pythonfan2 wrote:

Is there some higher-level access method I am missing or don't know about? Some parent object property?


There is the GetParent() method.

I think that you will have to use the UF-wrappers to get the objects internal type as @JimB mentioned.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.2, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Re: Getting correct builder from object?

Pioneer
Pioneer

@JimB Thanks for posting this table, very helpful. I am actually using this method currently, but I don't believe there is a uf_object_type distinguishment between mill_areas and workpieces - they both return type 105 subtype 10.  This is the snippet of code that currently helps me parse geometry object types:

            self.nx_type, self.nx_subtype = NXOpen_UF.UFSession.GetUFSession().Obj.AskTypeAndSubtype(self.NCGroup_object.Tag)
            if self.nx_type == 105 and self.nx_subtype == 10:
                #Note: Can be either workpiece geometry or mill area! 
                #Attempt to apply both updaters and see which one sticks
                self.workpiece_container = self.NCGroup_object
                try:
                    self.update_geometry()
                    self.disposition = 'workpiece'
                except:
                    #Well, it wasn't geometry.
                    pass
                try:
                    self.update_mill_area()
                    self.disposition = 'mill_area'
                except:
                    lw = self.theSession.ListingWindow
                    lw.Open()
                    lw.WriteLine('Object  ' + str(self.NCGroup_object.Name + 'does not match desired geom type'))
                    lw.WriteLine('Nx Type, Subtype = '  + str(self.nx_type) + ',' + str(self.nx_subtype))
                    lw.Close()
            if self.nx_type == 105 and self.nx_subtype == 30:
                self.MCS_container = self.NCGroup_object
                self.update_orientation()
                self.disposition = 'orientation_csys'

In this context the updaters are just subroutines that call the correct builder.

 

@cowski1 I'm not familiar with the .toolingmanger property and I can't seem to find it in the NXOpen python API reference for the part class - can you point me in the right direction? https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

 

I agree that python's internal type feature is useful in these cases; I generally prefer to avoid filtering objects by strings (old habit, I suppose).

 

@Stefan_Pendl I believe the GetParent() method will get the heirarchical parent in the machining geometry tree, but I think what I was asking is more "is there a parent class method that provides access to the correct builder for a given object type"

 

 

Re: Getting correct builder from object?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@cowski1 I'm not familiar with the .toolingmanger property and I can't seem to find it in the NXOpen python API reference for the part class - can you point me in the right direction? https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

 

I agree that python's internal type feature is useful in these cases; I generally prefer to avoid filtering objects by strings (old habit, I suppose).

I had the NX 9 NXOpen .net API reference open when I read your question; that's where I saw the .ToolingManager property. Perhaps it was not added to the python API, in which case... well, bummer. Perhaps call GTAC to see if there is an equivalent?

 

I also don't like comparing types by strings; the "str(type(myObj))" was just an example to output the object type to the listing window so I'd know what type of object my journal was dealing with. Once I know the object type, I'd use something like python's .isinstance method to test an arbitrary object vs. the type I was interested in.