[CommandMethod("Test", CommandFlags.UsePickSet)]publicstaticvoidTest(){Documentdoc=Application.DocumentManager.MdiActiveDocument;Databasedb=doc.Database;using(Transactiontr=db.TransactionManager.StartTransaction()){BlockTablebt=tr.GetObject(db.BlockTableId,OpenMode.ForRead)asBlockTable;BlockTableRecordbtr=tr.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite)asBlockTableRecord;// Define the center point, major axis, and minor axisPoint3dcenterBottom=newPoint3d(0,0,0);Point3dcenterTop=newPoint3d(0,1000,0);Vector3dmajorAxis=newVector3d(500,0,0);doubleminorAxisLength=300;doubleradiusRatio=minorAxisLength/majorAxis.Length;// Create the ellipse at bottomEllipseellipseBottom=newEllipse(centerBottom,Vector3d.ZAxis,majorAxis,radiusRatio,Math.PI,2*Math.PI);btr.AppendEntity(ellipseBottom);tr.AddNewlyCreatedDBObject(ellipseBottom,true);// Create the ellipse at topEllipseellipseTop=newEllipse(centerTop,Vector3d.ZAxis,majorAxis,radiusRatio,Math.PI,2*Math.PI);btr.AppendEntity(ellipseTop);tr.AddNewlyCreatedDBObject(ellipseTop,true);LineleftLine=newLine(ellipseTop.StartPoint,ellipseBottom.StartPoint);btr.AppendEntity(leftLine);tr.AddNewlyCreatedDBObject(leftLine,true);LinerightLine=newLine(ellipseTop.EndPoint,ellipseBottom.EndPoint);btr.AppendEntity(rightLine);tr.AddNewlyCreatedDBObject(rightLine,true);ObjectIdCollectionacObjIdColl=newObjectIdCollection();acObjIdColl.Add(ellipseBottom.ObjectId);acObjIdColl.Add(leftLine.ObjectId);acObjIdColl.Add(ellipseTop.ObjectId);acObjIdColl.Add(rightLine.ObjectId);// Create the hatch object and append it to the block table recordusing(HatchacHatch=newHatch()){btr.AppendEntity(acHatch);tr.AddNewlyCreatedDBObject(acHatch,true);// Set the properties of the hatch object// Associative must be set after the hatch object is appended to the // block table record and before AppendLoopacHatch.SetHatchPattern(HatchPatternType.PreDefined,"ANSI31");acHatch.Associative=true;acHatch.PatternScale=500;acHatch.AppendLoop(HatchLoopTypes.Outermost,acObjIdColl);acHatch.EvaluateHatch(true);}// Commit the transactiontr.Commit();}}