3D views in 2D and 3D synchronization must be signed into 3D elements by using two-dimensional elements. In the previous project test, this self-generated tubular circle is used temporarily:
Esrisimple3dlinestyle axisstyle = esrisimple3dlinestyle. esris3dlstube; is symbolic, but this built-in style cannot be expanded more. You still need to manually graphic it. Today, I spent half a day reading the official example, at last, the line symbol connecting the two points of the specified coordinate was merged into a cube, and some problems were encountered in the middle. I thought arcengine provided a very good API. I only used to input two vertices or a line, and then gave it a polygon, which could help me draw a cube along the line, however, if the location is incorrect or the angle is incorrect, the official example is too simple and cannot be used in my application, so I analyzed the cause and used the following three steps:
Step 1: The space has a root line, and the start and end points are certainly available. I want to mark the line as a cube, so the length of the two points must be used. We will draw a cube along the zcoordinate at the coordinate origin. The height is the length of the Line mentioned above.
Step 2: assume that the starting point of the line is (0, 0, 0), that is, the custom origin. Through the ivector3d interface, it is easy to get the offset angle of the line. In this way, the cube above is rotated twice at the origin to obtain the correct line segment direction.
Step 3: Move the cube in step 2 to the starting position to complete the process.
C # code
- Public static igeometry getcubetubebylinepoint (ipoint fpoint, ipoint tpoint, double width, double height)
- {
- // Ipoint fpoint = geometryutilities. constructpoint3d (5, 6, 3 );
- // Ipoint tpoint = geometryutilities. constructpoint3d (15, 13, 13 );
- // Calculate the coordinates --> move the coordinate origin
- Ivector3d tarpointv3d = geometryutilities. constructvector3d (tpoint. X-fpoint. X, tpoint. Y-fpoint. Y, tpoint. Z-fpoint. z );
- // Define the axis for two rotations
- Ivector3d axisofrotationvector3d_y = geometryutilities. constructvector3d (0, 10, 0 );
- Ivector3d axisofrotationvector3d_z = geometryutilities. constructvector3d (0, 0, 10 );
- // Define a line segment
- Iline extrusionline = new lineclass ();
- Extrusionline. frompoint = fpoint;
- Extrusionline. topoint = tpoint;
- Double mytoz = extrusionline. length; // Line Segment Length
- // Initialize the section shape
- Ipointcollection polygonpointcollection = new polygonclass ();
- Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (-(height/2), (width/2), ref _ missing, ref _ missing );
- Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (height/2), (width/2), ref _ missing, ref _ missing );
- Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (height/2),-(width/2), ref _ missing, ref _ missing );
- Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (-(height/2),-(width/2), ref _ missing, ref _ missing );
- Ipolympus Gon polygon = polygonpointcollection as ipolympus gon;
- Polygon. Close ();
- Igeometry polygongeometry = polygonpointcollection as igeometry;
- Itopologicaloperator topologicaloperator = polygongeometry as itopologicaloperator;
- Topologicaloperator. Simplify ();
- // Perform Extrusion
- Iconstructmultipatch constructmultipatch = new multipatchclass ();
- Constructmultipatch. constructextrudefromto (0, mytoz, polygongeometry );
- // Rotation Angle
- Itransform3d transform3d = constructmultipatch as itransform3d;
- Transform3d. rotatevector3d (axisofrotationvector3d_y, tarpointv3d. inclination );
- Transform3d. rotatevector3d (axisofrotationvector3d_z, geometryutilities. getradians (90)-tarpointv3d. Azimuth );
- // Move to the start point
- Transform3d. move3d (fpoint. X, fpoint. Y, fpoint. z );
- Return constructmultipatch as igeometry;
- }