[Closed] How to write on this plugin for naming edges?
local point3 ve1 = polyop.getVert pick.Object verts[1]
local point3 ve2 = polyop.getVert pick.Object verts[2]
local projx = abs( ve1.x - ve2.x as float) --7
local projy = abs( ve1.y - ve2.y as float) --0
local projz = abs( ve1.z - ve2.z as float) -- 0
local Largest = 1 as integer
if projx < 1.0e-6 and projy < 1.0e-6 do -- vertical
Largest = 1
if projy < 1.0e-6 and projz < 1.0e-6 do -- sideway
Largest = 2
if projx < 1.0e-6 and projz < 1.0e-6 do -- inner
Largest = 3
MessageBox (Largest as string)
Edge_Name = name
if Largest == 1 do
Edge_x = ve1.x as float
Edge_y = ve1.y as float
Edge_z = 0.0
else if Largest == 2 do
MessageBox (ve1.y as string)
Edge_x = 0.0
Edge_y = ve1.y as float
Edge_z = ve1.z as float
else if Largest == 3 do
Edge_x = ve1.x as float
Edge_y = 0.0
Edge_z = ve1.z as float
How come when the edge is sideways, Edge_y would become 0.0 while it isn’t the case
Okay, for the last time, then I give up:
try destroyDialog name_edge catch()
rollout name_edge "Name Edge"
(
fn isPoly obj = isKindOf obj Editable_Poly
fn getIndexOfMax x y z =
if x > y then (if x > z then 1 else 3)
else (if y > z then 2 else 3)
fn absP3 p3 =
[abs p3.x, abs p3.y, abs p3.z]
global Edge_Name
global Edge_Point3
editText name "Name: "
pickButton pick "NONE" autoDisplay:true filter:isPoly
on pick picked it do
(
if name.text.count < 1 do
return messageBox "Edge name cannot be empty"
if pick.object == undefined do
return messageBox "No object selected"
if pick.object.selectedEdges.count != 1 do
return messageBox "Exactly one edge has to be selected"
local verts = polyop.getEdgeVerts pick.object pick.object.selectedEdges[1].index
local v1 = polyop.getVert pick.Object verts[1]
local v2 = polyop.getVert pick.Object verts[2]
Edge_Name = name.text
local proj = absP3 (v1 - v2)
case (getIndexOfMax proj.x proj.y proj.z) of
(
1 : Edge_Point3 = Point3 0 proj.y proj.z
2 : Edge_Point3 = Point3 proj.x 0 proj.z
3 : Edge_Point3 = Point3 proj.x proj.y 0
)
messageBox (Edge_Name + " : " + Edge_Point3 as string)
)
)
createDialog name_edge
Thanks, it okay now.
But I am onto the SDK, for getting back the info from maxscript
I am looking for ways to map maxscript variable to the SDK
Value *x;
Value *y;
Value *z;
Value *Name;
Value* get_Edge_X()
{
return (Value*)x;
}
void SetEdgeX(Value* _x)
{
x = _x;
}
Value* set_Edge_X(Value* val)
{
SetEdgeX(val);
return val;
}
Value* get_Edge_Y()
{
return (Value*)y;
}
void SetEdgeY(Value * _y)
{
y = _y;
}
Value* set_Edge_Y(Value* val)
{
SetEdgeY(val);
return val;
}
Value* get_Edge_Z()
{
return (Value*)z;
}
void SetEdgeZ(Value *_z)
{
z = _z;
}
Value* set_Edge_Z(Value* val)
{
SetEdgeZ(val);
return val;
}
Value* get_Edge_Name()
{
return (Value*) Name;
}
void SetEdgeName(Value *_name)
{
Name = _name;
}
Value* set_Edge_Name(Value* val)
{
SetEdgeName(val);
return val;
}
void SimExporter::Init(HWND hWnd)
{
//MessageBox(NULL, "Here", "Here", NULL);
define_system_global("Edge_Name", get_Edge_Name, set_Edge_Name);
define_system_global("Edge_x", get_Edge_X, set_Edge_X);
define_system_global("Edge_y", get_Edge_Y, set_Edge_Y);
define_system_global("Edge_z", get_Edge_Z, set_Edge_Z);
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
OutputDebugString("XML Serializer init failed");
return;
}
}
When I try to retrieve the X value, I get a NULL
Value *x = get_Edge_X();
float val = x->to_float();
printf (“%f
“, val);
I am so mixed up now.
Could anyone supply a editable mesh version of this applet?
persistents.removeall()
if name.text.count < 1 do
return messageBox "Edge name cannot be empty"
if pick.object == undefined do
return messageBox "No object selected"
if pick.object.selectedEdges.count != 1 do
return messageBox "Exactly one edge has to be selected"
local verts = polyop.getEdgeVerts pick.object pick.object.selectedEdges[1].index
-- append edges (edgeInfo name:name.text v1:(polyop.getVert pick.object verts[1]) v2:((polyop.getVert pick.object verts[2])))
local point3 ve1 = polyop.getVert pick.Object verts[1]
local point3 ve2 = polyop.getVert pick.Object verts[2]
local projx = abs( ve1.x - ve2.x as float) --7
local projy = abs( ve1.y - ve2.y as float) --0
local projz = abs( ve1.z - ve2.z as float) -- 0
Thanks
Jack
local theObj = selection[1]
--local theEdge = getEdgeSelection theObj
local vert1 = getVert theObj 1
local vert2 = getVert theObj 2
The problem with this is the indices of 1 and 2 not always pointing to the the right edges. A mesh can contain a thousands of edges…
How do get the indices of the vertices of the edges currently selected?
Thanks
Jack
local theEdge = getEdgeSelection theObj
theEdge.showproperties
How come getEdgeSelection is undefined, is that a built in function for maxscript?
I have selected a mesh edge for sure.
Why?
Thanks
Jack