Esempio n. 1
0
	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() 
Esempio n. 2
0
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")
Esempio n. 3
0
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")
Esempio n. 4
0
 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 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)
Esempio n. 6
0
# now Offset is done, and shell is selected. Next we Separate it
mm.begin_tool(r, "separate")
mm.accept_tool(r)

# read back current selection (will be shell)
shell_objects = mm.list_selected_objects(r)
mm.set_object_name(r, shell_objects[0], "shell")

# set current as target (will be offset shell)
mm.set_as_target(r)

# restore original selection
mm.select_objects(r, initial_selection)

# select an area on the surface
(found,sfc_pt) = mm.find_nearest(r, (1,1,1))
mm.select_inside_sphere(r, sfc_pt.origin, mm.toS(r,10.0))

# run Attract to Target tool
mm.begin_tool(r, "attractToTarget")
mm.accept_tool(r)

# clear target and/or delete shell
#mm.clear_target(remote)
#mm.delete_objects(remote, shell_objects)

#done!
r.shutdown();


mm.accept_tool(r)

# now Offset is done, and shell is selected. Next we Separate it
mm.begin_tool(r, "separate")
mm.accept_tool(r)

# read back current selection (will be shell)
shell_objects = mm.list_selected_objects(r)
mm.set_object_name(r, shell_objects[0], "shell")

# set current as target (will be offset shell)
mm.set_as_target(r)

# restore original selection
mm.select_objects(r, initial_selection)

# select an area on the surface
(found, sfc_pt) = mm.find_nearest(r, (1, 1, 1))
mm.select_inside_sphere(r, sfc_pt.origin, mm.toS(r, 10.0))

# run Attract to Target tool
mm.begin_tool(r, "attractToTarget")
mm.accept_tool(r)

# clear target and/or delete shell
#mm.clear_target(remote)
#mm.delete_objects(remote, shell_objects)

#done!
r.shutdown()
# 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)

# exit out of selection tool
mm.clear_face_selection(remote)
for size in [0.5]:
    # import part we want to position at selection
    new_objs = mm.append_objects_from_file(remote, pipe_filename)

    # select imported part
    mm.select_objects(remote, new_objs)

    mm.begin_tool(remote, "transform")
    mm.set_toolparam(remote, "scale", [1, size, 1])
    #mm.set_toolparam(remote, "translation", [0,0,0])
    mm.accept_tool(remote)
Esempio n. 9
0
# 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)

# exit out of selection tool
mm.clear_face_selection(remote)

# import part we want to position at selection
new_objs = mm.append_objects_from_file(remote, part_filename);

# select imported part
mm.select_objects(remote, new_objs)

# get bbox of part, so that we can put origin at bottom of object if desired 
# (we are assuming that in its file, the part is positioned at the origin, on the ground plane)
(min,max) = mm.get_selected_bounding_box(remote)

# start transform tool
Esempio n. 10
0
print "scene bbox min: ", fMin
print "scene bbox max: ", fMax

# convert to world-space (ie current units)
fMinW = mm.to_world(r, fMin)
fMaxW = mm.to_world(r, fMax)
print "world bbox min: ", fMinW
print "world bbox max: ", fMaxW
print "one world unit in scene dimensions: ", mm.to_scene(r, 1.0)
print "\n"

# construct a ray from far-away-pt through center of bbox, along +Z axis
center = lerpv3(fMin, fMax, 0.5)
diag = subv3(fMax, fMin)
ray_dir = (0.0,0.0,1.0)
ray_origin = subv3(center, mulv3s(ray_dir, 25.0*max(diag)))

# hit-test ray against object
(bHit, hitFrame) = mm.find_ray_hit(r, ray_origin, ray_dir)
print "hit: ", bHit, " world pos: ", hitFrame.origin;

# find nearest point on sfc to (-2,0,0)
(bFound, nearFrame) = mm.find_nearest(r, (-2,0,0) )
print "found: ", bFound, " world pos: ", mm.toW(r, nearFrame.origin);

#done!
r.shutdown()