FN g_filter o = superclassof o = geometryclass
FN find_intersection z_node node_to_z =
(
-- The same conditional numbers and computation are faster than strings, so strings are not needed.
Oop = case
(
(Gt_yc_ail.conunt_spn1.value = 1): [0, 0,-1]
(Gt_yc_ail.conunt_spn1.value = 2): [0, 0, 1]
(Gt_yc_ail.conunt_spn1.value = 3): [-1, 0]
(Gt_yc_ail.conunt_spn1.value = 4): [1, 0]
(Gt_yc_ail.conunt_spn1.value = 5): [0,-1, 0]
(Gt_yc_ail.conunt_spn1.value = 6): [0, 1]
-- Default: Reference $ foo
)
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
Intersectray z_node testray
)
Try (destroydialog gt_yc_ail) catch ()
Rolout gt_yc_ail "yongchao-alignment" width: 168 Height: 80
(
Spinner conunt_spn1 "" POS: [152,25] width: 12 Height: 16 range: [, 1] type: # integer
Edittext conunt_edt1 "" POS: [147] width: Height: 16 text: "negative direction of the Z axis" enabled: false
Button pick_btn1 "Start alignment" POS: [6, 49] width: 142 Height: 24
Groupbox grp1 "axial Selection:" POS: [5, 9] width: 160 Height: 39
On conunt_spn1 changed Arg do
(
New_obj = case Arg
(
1: conunt_edt1.text = "negative direction of the Z axis"
2: conunt_edt1.text = "positive direction of the Z axis"
3: conunt_edt1.text = "negative direction of X axis"
4: conunt_edt1.text = "positive direction of the X axis"
5: conunt_edt1.text = "negative direction of Y axis"
6: conunt_edt1.text = "positive direction of the Y axis"
-- Default: Reference $ foo
)
)
On pick_btn1 pressed DO
(
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
If int_point! = Undefined then I. pos = int_point.pos
) -- end I loop
) -- end undo
) -- end if
) -- end pressed
)
createdialog gt_yc_ail style: # (# style_border, # style_titlebar, # style_resizing, # style_sysmenu)