Cancel
Showing results for 
Search instead for 
Did you mean: 

NX11 Python Obtain point coordinates from point object

Creator
Creator

Hello,

 

I am working on a python code NX11. I would like to attach a pmi note to a specific point I have. 

 

I made the point using the PointSetBuilder class and I am currently referencing the point using

 

nXObject1 = pointSetBuilder1.Commit() 

 

I would like to use the point referenced in the above object as the point where to put a pmi note so that the code looks something like this:

 

pmiNoteBuilder.Origin.Origin.SetValue(NXOpen.TaggedObject.Null, NXOpen.View.Null, Coordinates of nXObject1)...

 

Do you guys know how to achieve this?

 

Thanks in advance

5 REPLIES 5

Re: NX11 Python Obtain point coordinates from point object

Siemens Phenom Siemens Phenom
Siemens Phenom

PointSetBuilder is a pretty heavy way to create a single point. If you do choose this route, the builder will return a NXOpen.Features.PointSet object. This object has a GetPoints() method that will return a list of NXOpen.Point. You can iterate thorugh this list and get the NXOpen.Point.Coordinates() to get a NXOpen.Point3d object that contains the coordinates of the point (via X, Y, Z properties).

Re: NX11 Python Obtain point coordinates from point object

Creator
Creator

Hello Jim,

 

Thanks for the answer. Can I specify how you would go about using the nXObject1 reference to find the point of interest within the NXOpen.PointSet list. I guess something like this (pseudo code) maybe???

 

for point_set in NXOpen.Features.PointSet.GetPoints()     # Iterate thru all points in point set list

    if point_set is nXObect1                                               # Compare with referenced point

         point_coordinates  = NXOpen.Point.Coordinates()   # If point is referenced point, then store coordinates

   

 

Highlighted

Re: NX11 Python Obtain point coordinates from point object

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@DeepStuff wrote:

Hello Jim,

 

Thanks for the answer. Can I specify how you would go about using the nXObject1 reference to find the point of interest within the NXOpen.PointSet list. I guess something like this (pseudo code) maybe???

 

for point_set in NXOpen.Features.PointSet.GetPoints()     # Iterate thru all points in point set list

    if point_set is nXObect1                                               # Compare with referenced point

         point_coordinates  = NXOpen.Point.Coordinates()   # If point is referenced point, then store coordinates

   

 


The pseudo code above references the parent class definition, the journal will need to work with an actual, instantiated object to get the point information that you want.

 

The pointSetBuilder1.Commit method will return the newly created point set feature. This means that nXObject1 is your new point set feature. In this case, I think your code will look something like below (untested):

 

 

for a_point in nXObject1.GetPoints()     # Iterate thru all points in point set list
point_coordinates = a_point.Coordinates # store coordinates

 

 

Re: NX11 Python Obtain point coordinates from point object

Creator
Creator

Thank you cowski,

 

Now it says "'NXOpen.Point3d' object is not callable" when I attempt to store the coordinates on the point_coordinates  variable

Re: NX11 Python Obtain point coordinates from point object

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Get rid of the parentheses after the .Coordinates property name. I forgot to remove them when I copy & pasted the code (my post has been edited).

 

Yes:

point_coordinates  = a_point.Coordinates

No:

point_coordinates  = a_point.Coordinates()