×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX10 python journal - how to iterate through operation navigator - geometry view

NX10 python journal - how to iterate through operation navigator - geometry view

NX10 python journal - how to iterate through operation navigator - geometry view

(OP)
Hello everyone,

At first thank all of you for such amazing forum, I am able to find answer to my question nearly everytime.

But now I am solving journaling via python in NX 10. I would like to ask you how to iterate through all operations in operation navigator - geometry view.

For example I have several programs in this tree, I would like to get operation name, feed, spindle speed, stock, tool, operation time etc.

Could anybody provide me info how to do it via python?

Thank all of you for answers.

Nikola

RE: NX10 python journal - how to iterate through operation navigator - geometry view

FYI there are many vb samples for this, if that helps. Look at the OOTB “CycleAll” samples in UGOPEN\SampleNXOpenApplications\.NET\CAM.

Below is a python sample that should give you a good start.

If you have more questions, you may want to visit the Siemens PLM Programming and Customization Forum - a lot of API programmers also hang out there.

CODE --> python

import math
import NXOpen
import NXOpen.CAM

def get_group_objects(group_name):
    theSession = NXOpen.Session.GetSession()
    workPart = theSession.Parts.Work
    displayPart = theSession.Parts.Display

    find_it = workPart.CAMSetup.CAMOperationCollection.FindObject(group_name)

    new_objects = NXOpen.CAM.NCGroup.GetMembers(find_it)

    return new_objects

def output_message(dialog_name ,message_list):
    theSession = NXOpen.Session.GetSession()
    workPart = theSession.Parts.Work
    displayPart = theSession.Parts.Display

    get_ui = NXOpen.UI.GetUI()
    message_box = get_ui.NXMessageBox
    message_box.Show(dialog_name, NXOpen.NXMessageBox.DialogType.Information, message_list)

def main():
    theSession = NXOpen.Session.GetSession()
    workPart = theSession.Parts.Work
    displayPart = theSession.Parts.Display

    start_point = workPart.CAMSetup.CAMOperationCollection.FindObject("GEOMETRY")
    objects_at_start = NXOpen.CAM.NCGroup.GetMembers(start_point)

    group_list = []
    checked_list = []
    operation_list = []
    feed_rate_list = []
    spindle_rpm_list = []
    stock_value_list = []
    path_time_list = []
    cutting_tool_list = []

    for each_object in objects_at_start:
        if workPart.CAMSetup.IsGroup(each_object) == True:
            group_list.append(each_object.Name)
        elif workPart.CAMSetup.IsOperation(each_object) == True:
            operation_list.append(each_object.Name)
            cutting_tool = each_object.GetParent(NXOpen.CAM.CAMSetupView.MachineTool)
            cutting_tool_list.append(cutting_tool.Name)
            stock_value_list.append(str(each_object.GetRealValue("Stock Part")))
            spindle_rpm_list.append(str(each_object.GetRealValue("Spindle RPM")))
            feed_rate_tuple = each_object.GetFeedRate("Feed Cut")
            if feed_rate_tuple[0] == NXOpen.CAM.CAMObjectFeedRateUnit.PerMinute:
                feed_rate_units = "mm per Minute"
            elif feed_rate_tuple[0] == NXOpen.CAM.CAMObjectFeedRateUnit.PerRevolution:
                feed_rate_units = "mm per revolution"
            else:
                feed_rate_units = "None"
            feed_rate_list.append(str(feed_rate_tuple[1]) + feed_rate_units)
            path_time_list.append(str(sub_object.GetToolpathTime()))

    while group_list != checked_list:
        for each_object in group_list:
            if each_object not in checked_list:
                temp_objects = get_group_objects(each_object)
                for sub_object in temp_objects:
                    if workPart.CAMSetup.IsGroup(sub_object) == True:
                        group_list.append(sub_object.Name)
                    elif workPart.CAMSetup.IsOperation(sub_object) == True:
                        operation_list.append(sub_object.Name)
                        cutting_tool = sub_object.GetParent(NXOpen.CAM.CAMSetupView.MachineTool)
                        cutting_tool_list.append(cutting_tool.Name)
                        stock_value_list.append(str(sub_object.GetRealValue("Stock Part")))
                        spindle_rpm_list.append(str(sub_object.GetRealValue("Spindle RPM")))
                        feed_rate_tuple = sub_object.GetFeedRate("Feed Cut")
                        if feed_rate_tuple[0] == NXOpen.CAM.CAMObjectFeedRateUnit.PerMinute:
                            feed_rate_units = "mm per minute"
                        elif feed_rate_tuple[0] == NXOpen.CAM.CAMObjectFeedRateUnit.PerRevolution:
                            feed_rate_units = "mm per revolution"
                        else:
                            feed_rate_units = "None"
                        feed_rate_list.append(str(feed_rate_tuple[1]) + feed_rate_units)
                        path_time_list.append(str(sub_object.GetToolpathTime()))
                checked_list.append(each_object)

    temp_list = []

    if operation_list == []:
        output_message("No Path", "There are no operations to report.")
    else:
        for i in range(len(operation_list)):
            temp_list.append("Path: " + operation_list[i] + " Tool: " + cutting_tool_list[i])
        output_message("Cutting Tools", temp_list)
        temp_list = []
        for i in range(len(operation_list)):
            temp_list.append("Path: " + operation_list[i] + " RPM: " + spindle_rpm_list[i])
        output_message("Spindle Speeds", temp_list)
        temp_list = []
        for i in range(len(operation_list)):
            temp_list.append("Path: " + operation_list[i] + " Feed Rate: " + feed_rate_list[i])
        output_message("Feed Rate", temp_list)
        temp_list = []
        for i in range(len(operation_list)):
            temp_list.append("Path: " + operation_list[i] + " Stock: " + stock_value_list[i])
        output_message("Part Stock", temp_list)
        temp_list = []
        for i in range(len(operation_list)):
            temp_list.append("Path: " + operation_list[i] + " Seconds: " + spindle_rpm_list[i])
        output_message("Time", temp_list)

main() 

Mark Rief
NX CAM Customer Success
Siemens PLM Software

RE: NX10 python journal - how to iterate through operation navigator - geometry view

(OP)
Hello Mark,

thank you so much! This is great example. I am playing with this code it is really works.

Thank you.

Nikola

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources