111,119
社区成员
发帖
与我相关
我的任务
分享public struct MY_POS
{
public double x;
public double y;
public double z;
}
double[] pos = {}; //定义全局变量
private void button8_Click(object sender, EventArgs e)
{
string[] t = textBox5.Text.Split("->".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
MY_POS[] pos = new MY_POS[t.Length];
for (int W = 0; W < t.Length; W++)
{
pos[W].x = matrix[0];
pos[W].y = matrix[1];
pos[W].z = matrix[2];
}
}
}
}for (int i = 0; i < Selection.ItemCount; i++)
{
comp = (IvcComponent)Selection.getItem(i);
object name = comp.getProperty("Name");
double[] matrix = (double[])comp.RootNode.getProperty("WorldPositionMatrix");//获得坐标下x,y,z的坐标
pos = new MY_POS[i];
pos[i].x = matrix[0];
pos[i].y = matrix[1];
pos[i].z = matrix[2];
if (textBox5.Text != "")
{
textBox5.Text += "->" + name.ToString();
}
else
{
textBox5.Text = name.ToString();
}
}string[] t = textBox5.Text.Split("->".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
double dis = 0;
for (int W = 1; W < t.Length; W++)
{
double xd = pos[W].x - pos[W - 1].x;
double yd = pos[W].y - pos[W - 1].y;
double zd = pos[W].z - pos[W - 1].z;
dis += Math.Sqrt(xd * xd + yd * yd + zd * zd);
textBox6.Text = dis.ToString();
}为什么dis的值还是0呢......我看了下pos[W].x和 pos[W - 1].x结果是一样的,这是为什么啊,应该不一样啊