2,854 questions
Show and Hide Objects of type GemetryModel3d in WPF Viewport3d
Marino Liranzo
81
Reputation points
Hello friend of the forum I am breaking my head trying to show and hide several texts made with a class that uses GeometryModel3D elements, the texts must be shown in a viewport3D when a bool type variable is true and hidden when the variable is false. I have dealt with the following code.
void MostrarPropiedadesDimension(Model3DGroup modelg)
{
Brush colorTexto = colortextos;
GeometryModel3D textLong = null;
modelg.Children.Remove(textLong); // modelg is a Model3DGroup Element
model_visual.Content = modelg; // model_visual is a ModelVisual3D Element
if (chkLong) // bool variable from a checkbox
{
for (int i = 0; i < Shapes3D.Count; i++)
{
double x = Shapes3D[i].Pt13D.X; // Start point X of line elements
double x2 = Shapes3D[i].Pt23D.X; // End point X of line elements
double y = Shapes3D[i].Pt13D.Y; // Start point Y of line elements
double y2 = Shapes3D[i].Pt23D.Y; // End point Y of line elements
double z = Shapes3D[i].Pt13D.Z; // Z coordinate of the points of line elements
if (Shapes3D[i].Pt13D.Y.Equals(Shapes3D[i].Pt23D.Y))
{
// CreateTextLabelModel3D is a static method of the TextCreator static Class
textLong = TextCreator.CreateTextLabelModel3D((x2 - x).ToString(), colorTexto,
false, .3, new Point3D(x + (x2 - x) / 2 - 0.1, y + 0.25, z), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
}
else if (Shapes3D[i].Pt13D.X.Equals(Shapes3D[i].Pt23D.X))
{
textLong = TextCreator.CreateTextLabelModel3D((Math.Abs(y2 - y)).ToString(), colorTexto,
false, .3, new Point3D(x - 0.25, y + (y2 - y) / 2 - 0.1, z), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
}
modelg.Children.Add(textLong);
}
}
}
Developer technologies | Windows Presentation Foundation
Sign in to answer