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
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
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
thank you so much! This is great example. I am playing with this code it is really works.
Thank you.
Nikola