******************* **************************************** ***-----------
Try (Cui. unregisterdialogbar transpivot) catch () ----- This is the rule.
Try (destroydialog transpivot) catch ()
Global gt_yc_ail
FN g_filter o = superclassof o = geometryclass
FN find_intersection z_node node_to_z =
(
Try (
-- The same conditional numbers and computation are faster than strings, so strings are not needed.
--- Changed to Automatic loop processing. I only considered 6 items to be rubbed in a loop.
Local OOP
Local compare_array = #()
For I in 1 to 6 do
(
Oop = case
(
(I = 1): [0, 0,-1]
(I = 2): [0, 0, 1]
(I = 3): [-1, 0]
(I = 4): [1, 0, 0]
(I = 5): [0,-1, 0]
(I = 6): [0, 1]
-- Default: Reference $ foo
)
-- Print OOP
Local testray = Ray node_to_z.pos OOP
Local nodemaxz
Case oop
(------ Z axis
([0, 0,-1]) :( nodemaxz = z_node.max.z
Testray. Pos. z = nodemaxz + 0.0001 * ABS nodemaxz
)
([0, 0, 1]) :( nodemaxz = z_node.min.z
Testray. Pos. z = nodemaxz-0.0001 * ABS nodemaxz
)
------- X axis
([-1, 0, 0]): (nodemaxz = z_node.max.x
Testray. Pos. x = nodemaxz + 0.0001 * ABS nodemaxz
)
([1, 0, 0]): (nodemaxz = z_node.min.x
Testray. Pos. x = fig-0.0001 * ABS nodemaxz
)
------- Y axis
([0,-1, 0]): (nodemaxz = z_node.max.y
Testray. Pos. Y = nodemaxz + 0.0001 * ABS nodemaxz
)
([0, 0]): (nodemaxz = z_node.min.y
Testray. Pos. Y = fig-0.0001 * ABS nodemaxz
)
)
--)
-- Testray. Pos. z = nodemaxz + 0.0001 * ABS nodemaxz
If intersectray z_node testray! = Undefined then
(
--- Because I first set the negative direction of the X axis, in fact, the two directions are that my colleagues have all the good options for comparison.
-- Return
Append compare_array (intersectray z_node testray)
-- Exit
)
)/*
For I in compare_array do
(
Distance_d = distance $ Selection [1]. pos I. Pos
-- Print compare_array [1]. Pos
Distance_c = 0
If distance_d> = distance_c then
(
Distance_c = distance_d
)
)*/
--- In fact, there are two better ones. Use the column method.
Distance_d = distance $ Selection [1]. Pos compare_array [1]. Pos
Try (distance_c = distance $ Selection [1]. Pos compare_array [2]. Pos)
Catch (distance_c = distance_d + 20)
If Amin distance_d distance_c = distance_d then
(
Return compare_array [1]
) Else
(
Return compare_array [2]
)
) Catch ()
)
Rolout transpivot "" width: 160 Height: 344
(
Local aligntoobj = 0,
Usepivot
Pickbutton alobj "alignto :( onesel/...)" POS: [104] width: Height: 15
Button alsel "clear" POS: [114,4] width: 35 Height: 15
Button al5 "x_max" POS: [4, 30] width: 70 Height: 18
Button al6 "x_min" POS: [81,29] width: 70 Height: 18
Button al1 "y_max" POS: [4, 52] width: 70 Height: 18
Button A3 "y_min" POS: [81,51] width: 70 Height: 18
Button Al "z_max" POS: [4, 74] width: 70 Height: 18
Button al4 "z_min" POS: [81,73] width: 70 Height: 18
Button ALB "center" POS: [4, 96] width: 70 Height: 18
Button ALR "random" POS: [81,95] width: 70 Height: 18
Spinner mult "rate" POS: [10,119] width: 55 Height: 16 range: [, 1]
Spinner multr "random rate" POS: [85,120] width: 70 Height: 16 range: [, 0]
Button pick_btn1 "automatic alignment" POS: [40,142] width: 70 Height: 18 enabled: True
----------------------
FN rotatepivotonly OBJ rotation =
(
Local rotvalinv = rotation as quat
Animate off
In coordsys local obj. Rotation * = rotvalinv
OBJ. objectoffsetrot * = rotvalinv
OBJ. objectoffsetpos * = rotvalinv
)
On alobj picked OBJ do (aligntoobj = OBJ; alobj. TEXT = ("alignto:" + obj. name); SEL = getcurrentselection (); for I = 1 to SEL. count do (resetpivot sel [I]; rotatepivotonly sel [I] aligntoobj. rotation; SEL [I]. dependencies = aligntoobj. ))
On alsel pressed do (aligntoobj = 0; alobj. Text = "alignto :( onesel /...)")
On al1 pressed do (SEL = getcurrentselection (); for I = 1 to SEL. count do (OBJ = If aligntoobj = 0 then sel [I] else aligntoobj; SEL [I]. invalid. y = obj. max. Y + (mult. value-1 + random 0.0 multr. value) * (obj. max. y-obj.min.y )))
On Al2O3 pressed do (SEL = getcurrentselection (); for I = 1 to SEL. count do (OBJ = If aligntoobj = 0 then sel [I] else aligntoobj; SEL [I]. invalid. z = obj. max. Z + (mult. value-1 + random 0.0 multr. value) * (obj. max. z-obj.min.z )))
On _3 pressed do (SEL = getcurrentselection (); for I = 1 to SEL. count do (OBJ = If aligntoobj = 0 then sel [I] else aligntoobj; SEL [I]. invalid. y = obj. min. y-(mult. value-1 + random 0.0 multr. value) * (obj. max. y-obj.min.y )))
On al4 pressed do (SEL = getcurrentselection (); for I = 1 to SEL. count do (OBJ = If aligntoobj = 0 then sel [I] else aligntoobj; SEL [I]. invalid. z = obj. min. z-(mult. value-1 + random 0.0 multr. value) * (obj. max. z-obj.min.z )))
On al5 pressed do (SEL = getcurrentselection (); for I = 1 to SEL. count do (OBJ = If aligntoobj = 0 then sel [I] else aligntoobj; SEL [I]. invalid. X = obj. max. X + (mult. value-1 + random 0.0 multr. value) * (obj. max. x-obj.min.x )))
On al6 pressed do (SEL = getcurrentselection (); for I = 1 to SEL. count do (OBJ = If aligntoobj = 0 then sel [I] else aligntoobj; SEL [I]. invalid. X = obj. min. x-(mult. value-1 + random 0.0 multr. value) * (obj. max. x-obj.min.x )))
On 1C pressed do (
Sel = getcurrentselection ()
For I = 1 to SEL. Count do
(
OBJ = If aligntoobj = 0 then sel [I] else aligntoobj
Sel [I]. invalid. X = obj. min. * + 0.5 * (obj. max. x-obj.min.x); SEL [I]. invalid. y = obj. min. Y + 0.5 * (obj. max. y-obj.min.y); SEL [I]. invalid. z = obj. min. Z + 0.5 * (obj. max. z-obj.min.z ))
)
On ALR pressed do (
Sel = getcurrentselection ()
For I = 1 to SEL. Count do
(
OBJ = If aligntoobj = 0 then sel [I] else aligntoobj
Sel [I]. invalid. X = random (obj. min. x-(mult. value-1 + random 0.0 multr. value) * (obj. max. x-obj.min.x) (obj. max. X + (mult. value-1 + random 0.0 multr. value) * (obj. max. x-obj.min.x ))
Sel [I]. invalid. y = random (obj. min. y-(mult. value-1 + random 0.0 multr. value) * (obj. max. y-obj.min.y) (obj. max. Y + (mult. value-1 + random 0.0 multr. value) * (obj. max. y-obj.min.y ))
Sel [I]. invalid. z = random (obj. min. z-(mult. value-1 + random 0.0 multr. value) * (obj. max. z-obj.min.z) (obj. max. Z + (mult. value-1 + random 0.0 multr. value) * (obj. max. z-obj.min.z ))
)
)
On pick_btn1 pressed do
(
--- Execute from top to bottom. Run this command first.
Target_mesh = pickobject message: "Pick target surface:" filter: g_filter --- this method is better. No more display;
If isvalidnode target_mesh then --- this is useful if the node is not deleted.
(
Undo "movetosurface" on
(
For I in selection do
(
Int_point = find_intersection target_mesh I
-- Print int_point as string
If int_point! = Undefined and int_point! = OK then
(
I. Pos = int_point.pos
-- Print int_point.pos
)
) -- End I loop
) -- End undo
) -- End if
) -- End pressed
On transpivot open do (usecenters = getcoordcenter (); toolmode. effectcenter ())
On transpivot close do case usepivot of (# local: toolmode. Skip tcenter (); # Selection: toolmode. selectioncenter (); # system: toolmode. transformcenter ())
) -- End rolout
Createdialog transpivot POS :( mouse. screenpos-[10,180])
Cui. registerdialogbar transpivot style: # (# cui_dock_left, # cui_dock_right, # cui_floatable)
Cui. dockdialogbar transpivot # cui_dock_right