def OnClick(self, e): obj_list = mm.list_selected_objects(remote) mm.select_objects(remote, [obj_list[0]]) cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: self.text.SetValue("Error! Please select an area") else: self.text.SetValue("Computing...") centroid = mm.get_face_selection_centroid(remote) (bFound, Frame) = mm.find_nearest(remote, centroid) flag_done=0 for size in hole_sizes: if size in used_sizes: continue print("Test:"+str(size)+":"+str(TestFit(Frame,[size,size,size],5))) if TestFit(Frame,[size,size,size],5): print("Created size with"+str(size)) used_sizes.append(size) create_ring(Frame,[8,2,8]) drill_holes(Frame,pipe_filename,[1,0.5,1],0,0) drill_holes(Frame,hole_filename,[size,size,size],5,1) flag_done=1 break if flag_done==0: self.text.SetValue("Unable to create hole here, Please select another area") else: dlg = wx.TextEntryDialog(self,'What you want here', 'Text Entry Dialog','',wx.ICON_QUESTION | wx.OK | wx.CANCEL,(dis_size[0]-300,200)) if dlg.ShowModal() == wx.ID_OK: function_call[size]=str(dlg.GetValue()) pickle.dump(function_call,open( "function_dict.p", "wb")) self.text.SetValue("updated:"+dlg.GetValue()) dlg.Destroy()
def addPosition(event): cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: setStatusText("Error! Please select an area") else: centroid = mm.get_face_selection_centroid(remote) (bFound, Frame) = mm.find_nearest(remote, centroid) selected_area.append(Frame) mm.clear_face_selection(remote) setStatusText("Position Added")
def addPosition(event): """ Function that is called when "Add Position" is pressed """ # check that we have a selection cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: setStatusText("Error! Please select an area") else: centroid = mm.get_face_selection_centroid(remote) sel_ctr = centroid (bFound, Frame) = mm.find_nearest(remote, sel_ctr) selected_area.append(Frame) mm.clear_face_selection(remote) setStatusText("Position Added")
def OnAdd(self, e): global frame_dict cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: self.text.SetValue("Error! Please select an area") else: centroid = mm.get_face_selection_centroid(remote) (bFound, Frame) = mm.find_nearest(remote, centroid) create_ring(mm.list_selected_objects(remote)[0], Frame, [8, 2, 8]) selected_area.append(Frame) mm.clear_face_selection(remote) dlg = wx.TextEntryDialog(self, 'What you want here', 'Text Entry Dialog', '', wx.ICON_QUESTION | wx.OK | wx.CANCEL, (dis_size[0] - 400, 300)) if dlg.ShowModal() == wx.ID_OK: frame_dict[Frame] = str(dlg.GetValue()) dlg.Destroy() self.text.SetValue("Position Added")
def connector_plane_cut(do_accept): remote = mmRemote(); remote.connect(); # accept outstanding tools, if there are any mm.accept_tool(remote) # get bbox of connector mm.select_object_by_name(remote, ConnectorName() ) (min,max) = mm.get_selected_bounding_box(remote) partCenter = ( (min[0]+max[0])/2, (min[1]+max[1])/2, (min[2]+max[2])/2 ) partH = max[1]-min[1] mm.select_object_by_name(remote, SocketName() ) # shoot ray upwards to hit exterior of socket, and then get facegroup of outer shell (bounds_min, bounds_max) = mm.get_selected_bounding_box(remote) bounds_ctr = mm.mulvs(mm.addv3(bounds_min, bounds_max), 0.5) mm.begin_tool(remote, "select") mm.select_hit_triangle(remote, mm.addv3(bounds_ctr, (0,-10,0)), (0,1,0) ) groups = mm.list_selected_groups(remote) # select outer shell facegroup and start plane cut mm.select_facegroups(remote, groups) mm.begin_tool(remote, "planeCut") # position cutting plane at offset from part mm.set_toolparam(remote, "fillType", 0) planeNormal = (0,1,0) #mm.set_toolparam(remote, "normal", planeNormal ) planeOrigin = max planeOrigin = mm.addv3( planeOrigin, mm.mulv3s(planeNormal, 0.5*partH) ) mm.set_toolparam(remote, "origin", planeOrigin) if do_accept: mm.accept_tool(remote) remote.shutdown()
def connector_plane_cut(do_accept): remote = mmRemote(); remote.connect(); # accept outstanding tools, if there are any mm.accept_tool(remote) # get bbox of connector mm.select_object_by_name(remote, ConnectorName() ) (min,max) = mm.get_selected_bounding_box(remote) partCenter = ( (min[0]+max[0])/2, (min[1]+max[1])/2, (min[2]+max[2])/2 ) partH = max[1]-min[1] mm.select_object_by_name(remote, SocketName() ) # shoot ray upwards to hit exterior of socket, and then get facegroup of outer shell (bounds_min, bounds_max) = mm.get_selected_bounding_box(remote) bounds_ctr = mm.mulvs(mm.addv3(bounds_min, bounds_max), 0.5) mm.begin_tool(remote, "select") mm.select_hit_triangle(remote, mm.addv3(bounds_ctr, (0,-10,0)), (0,1,0) ) groups = mm.list_selected_groups(remote) # select outer shell facegroup and start plane cut mm.select_facegroups(remote, groups) mm.begin_tool(remote, "planeCut") # position cutting plane at offset from part mm.set_toolparam(remote, "fillType", 0) #planeNormal = (0,1,0) #mm.set_toolparam(remote, "normal", planeNormal ) planeOrigin = max planeOrigin = mm.addv3( planeOrigin, mm.mulv3s(planeNormal, 0.5*partH) ) mm.set_toolparam(remote, "origin", planeOrigin) if do_accept: mm.accept_tool(remote) remote.shutdown()
def addPosition(event): obj_list = mm.list_selected_objects(remote) mm.select_objects(remote, [obj_list[0]]) # check that we have a selection cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: setStatusText("Error! Please select an area") else: print("1:") setStatusText("Computing...") centroid = mm.get_face_selection_centroid(remote) (bFound, Frame) = mm.find_nearest(remote, centroid) flag_done = 0 for size in hole_sizes: if size in used_sizes: continue print("Test:" + str(size) + ":" + str(TestFit(Frame, [size, size, size], 5))) if TestFit(Frame, [size, size, size], 5): print("Created size with" + str(size)) used_sizes.append(size) create_ring(Frame, [8, 2, 8]) drill_holes(Frame, pipe_filename, [1, 0.5, 1], 0, 0) drill_holes(Frame, hole_filename, [size, size, size], 5, 1) flag_done = 1 break print("2:" + str(flag_done)) if flag_done == 0: setStatusText( "Unable to create hole here, Please select another area") else: #text = ask(message = 'What do you want to do here?') #function_call[size]=text #pickle.dump( function_call, open( "function_dict.p", "wb" ) ) setStatusText("Position added, now you can select another area") #selected_area.append(Frame) mm.clear_face_selection(remote)
# selection examples: # - list selected objects # - list selected facegroups import mmapi from mmRemote import * import mm # initialize connection remote = mmRemote() remote.connect() # print list of selected object IDs selected_objects = mm.list_selected_objects(remote) print "selected objects: ", selected_objects # print list of selected group IDs (empty if no selection) groups_list = mm.list_selected_groups(remote) print "selected groups: ", groups_list #done! remote.shutdown()
import sys import mmapi from mmRemote import * import mm # assumption: we are running examples_dir = os.getcwd() part_filename = os.path.join(examples_dir, "hole.obj") pipe_filename = os.path.join(examples_dir, "pipe.obj") # initialize connection remote = mmRemote() remote.connect() # check that we have a selection cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: print "this script requires an active Face Selection" raw_input("Press Enter to exit...") os._exit(1) # assumption: we have object we want to modify selected, # and there is a selection made on this object obj_list = mm.list_selected_objects(remote) # find center of current selection, and then closest point on surface # this gives us a 3D frame we can align an object to centroid = mm.get_face_selection_centroid(remote) sel_ctr = centroid (bFound, selFrame) = mm.find_nearest(remote, sel_ctr)
import os import sys import mmapi from mmRemote import * import mm # assumption: we are running examples_dir = os.getcwd() part_filename = os.path.join( examples_dir, "cylinder.obj" ) # initialize connection remote = mmRemote() remote.connect() # check that we have a selection cur_groups = mm.list_selected_groups(remote) if len(cur_groups) == 0: print "this script requires an active Face Selection" raw_input("Press Enter to exit...") os._exit(1) # assumption: we have object we want to modify selected, # and there is a selection made on this object obj_list = mm.list_selected_objects(remote) # find center of current selection, and then closest point on surface # this gives us a 3D frame we can align an object to centroid = mm.get_face_selection_centroid(remote) sel_ctr = centroid (bFound, selFrame) = mm.find_nearest(remote, sel_ctr)