Select multiple lines in the CAD model space and create a view in the specified layout. The method is as follows:
1 /// <summary> 2 /// create a 3 // </Summary> 4 /// <Param name = "roundline"> model space multi-line </Param> 5 // <Param name = "curentlayout"> current layout name </param> 6 /// <Param name = "insertpoint"> insert point of the layout space view </Param> 7 // <Param name = "scale"> scale </param> 8 private void makeviewport (polyline roundline, string curentlayout, point3d insertpoint, double scale) 9 {10 database DB = hostapplicationservices. workingdatabase; 11 using (transaction TRAN = dB. transactionmanager. starttransaction () 12 {13 blocktable bt = Tran. getObject (dB. blocktableid, openmode. forread) as blocktable; 14 blocktablerecord BTR = Tran. getObject (BT [blocktablerecord. paperspace], openmode. forwrite) as blocktablerecord; 15 16 polyline bound = roundline. clone () as polyline; 17 bound. closed = true; 18 point3d maxpoint = bound. geometricextents. maxpoint; 19 point3d minpoint = bound. geometricextents. minpoint; 20 point3d centerpoint = new point3d (maxpoint. X + minpoint. x)/2, (maxpoint. Y + minpoint. y)/2, 0); 21 bound. transformby (matrix3d. scaling (scale, centerpoint); 22 bound. transformby (matrix3d. displacement (centerpoint. getvectorto (insertpoint); 23 BTR. appendentity (bound); 24 Tran. addnewlycreateddbobject (bound, true); 25 26 viewport Vp = new viewport (); 27 BTR. appendentity (VP); 28 Tran. addnewlycreateddbobject (VP, true); 29 VP. nonrectclipentityid = bound. ID; 30 31 VP. centerpoint = insertpoint; // specifies the position of the insert into the view. viewcenter = new point2d (centerpoint. x, centerpoint. y); // model space center position 33 34 VP. viewheight = maxpoint. y-minpoint. y; // model space height 35 VP. height = scale * VP. viewheight; // the height of a 36 VP. nonrectclipon = true; 37 VP. locked = true; 38 VP. on = true; 39 Tran. commit (); 40} 41}
CAD creates an irregular-shape View