Hatching array of circles in AutoCAD using c# -
i beginner in autocad plugins
.i have created array of circle using following code. now, have hatch circles in array .how that??how hatch circles @ once? moreover, how can return hatch method , use hatch objects.sorry language.thanks in advance.
[assembly: commandclass(typeof(beamsection.class1))] namespace beamsection { public class class1 { //class1 obj = new class1(); [commandmethod("beamatsupport")] public void addlightweightpolyline() { // current document , database document acdoc = application.documentmanager.mdiactivedocument; database accurdb = acdoc.database; promptpointresult ppr = acdoc.editor.getpoint("\nselect starting point "); var ucs = acdoc.editor.currentusercoordinatesystem; point3d startingpt = ppr.value.transformby(ucs); list<double> radius = new list<double>(); radius.add(0.5); radius.add(1); double[] pickpont = new double[3]; pickpont = new double[3]; pickpont[0] = startingpt[0]; pickpont[1] = startingpt[1]; pickpont[2] = startingpt[2]; double w = 12.0; double b = 18.0; double t = 1.0; double c = 1.0; int nb = 3; // start transaction using (transaction actrans = accurdb.transactionmanager.starttransaction()) { // open block table read blocktable acblktbl; acblktbl = actrans.getobject(accurdb.blocktableid, openmode.forread) blocktable; //open block table record model space write blocktablerecord acblktblrec; acblktblrec = actrans.getobject(acblktbl[blocktablerecord.modelspace], openmode.forwrite) blocktablerecord; pickpont[0] = startingpt[0]; pickpont[1] = startingpt[1]; pickpont[2] = startingpt[2]; application.showalertdialog(pickpont[0].tostring()); double x = calculate(w, b, c, radius, nb); circle accircle = new circle(); accircle.radius = 1.5 * 0.5; accircle.center = new point3d(pickpont[0] - (w / 2 - 2 * c) - x - 0.1, pickpont[1] + 2 * c, 0); //acblktblrec.appendentity(accircle); //actrans.addnewlycreateddbobject(accircle, true); /* objectidcollection objcolls = new objectidcollection(); objcolls.add(accircle.objectid); hatch ohatch = new hatch(); ohatch.elevation = 0.0; ohatch.patternscale = 2.0; ohatch.sethatchpattern(hatchpatterntype.predefined, "solid"); ohatch.colorindex = 4; ohatch.associative = true; ohatch.appendloop(hatchlooptypes.outermost, objcolls); ohatch.evaluatehatch(true);*/ //objectidcollection objcolls = new objectidcollection(); //objcolls.add(accircle.objectid); /* matrix3d curucsmatrix = acdoc.editor.currentusercoordinatesystem; coordinatesystem3d curucs = curucsmatrix.coordinatesystem3d; vector2d acvec2dang = new vector2d(curucs.xaxis.x, curucs.xaxis.y);*/ //darrayang = darrayang; //+ acvec2dang.angle; int nrows = 1; int ncolumns = nb; double drowoffset = 1; double dcolumnoffset = x; application.showalertdialog(x.tostring()); double darrayang = 0; (int = 0; < 2; i++) { extents3d acexts = accircle.bounds.getvalueordefault(); point2d acpt2darraybase = new point2d(acexts.minpoint.x, acexts.maxpoint.y); if (i == 1) { accircle.center = new point3d(pickpont[0] - (w / 2 - 2 * c) - x - 0.1, pickpont[1] + 2 * c, 0); } else { accircle.center = new point3d(pickpont[0] - (w / 2 - 2 * c) - x - 0.1, pickpont[1] + (b - 3 * t) + 1, 0); } dbobjectcollection acdbobjcollcols = new dbobjectcollection(); acdbobjcollcols.add(accircle); int ncolumnscount = 1; while (ncolumns >= ncolumnscount) { entity acentclone = accircle.clone() entity; acdbobjcollcols.add(acentclone); // caclucate new point copied object (move) point2d acpt2dto = polarpoints(acpt2darraybase, darrayang, dcolumnoffset * ncolumnscount); vector2d acvec2d = acpt2darraybase.getvectorto(acpt2dto); vector3d acvec3d = new vector3d(acvec2d.x, acvec2d.y, 0); acentclone.transformby(matrix3d.displacement(acvec3d)); acblktblrec.appendentity(acentclone); actrans.addnewlycreateddbobject(acentclone, true); ncolumnscount = ncolumnscount + 1; } double dang = math.pi / 2; dbobjectcollection acdbobjcolllvls = new dbobjectcollection(); foreach (dbobject acobj in acdbobjcollcols) { acdbobjcolllvls.add(acobj); } foreach (entity acent1 in acdbobjcollcols) { int nrowscount = 1; while (nrows > nrowscount) { entity acentclone = acent1.clone() entity; acdbobjcolllvls.add(acentclone); // caclucate new point copied object (move) point2d acpt2dto = polarpoints(acpt2darraybase, darrayang + dang, drowoffset * nrowscount); vector2d acvec2d = acpt2darraybase.getvectorto(acpt2dto); vector3d acvec3d = new vector3d(acvec2d.x, acvec2d.y, 0); acentclone.transformby(matrix3d.displacement(acvec3d)); acblktblrec.appendentity(acentclone); actrans.addnewlycreateddbobject(acentclone, true); nrowscount = nrowscount + 1; } } } //acblktblrec.appendentity(ohatch); // actrans.addnewlycreateddbobject(ohatch, true); actrans.commit(); } acdoc.sendstringtoexecute("._zoom _e ", true, false, false); }
you can see doc. add hatch first circle before creating array both entities.
please, clean code before posting should easier read try help.
Comments
Post a Comment