Autocad.net/c#.net QQ Group: 193522571 Delete Group (group) dimension Line (dimension)

Source: Internet
Author: User

         Public voiddeletedimension () {//Defining a DatabaseDatabase db =hostapplicationservices.workingdatabase; //Get current fileDocument doc =Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; //gets the current command-line objectEditor ed =Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; using(Transaction trans =db. Transactionmanager.starttransaction ()) {#regionDelete a group//Define a group dictionaryDbdictionary groupdict =(dbdictionary) db.                Groupdictionaryid.getobject (Openmode.forread); //Search for group objects that meet the criteria in a group dictionary                foreach(DictionaryEntry IDEinchgroupdict) {                    //Get Group ObjectAcadgroup Partgroup =(Acadgroup) trans. GetObject (ObjectId) IDE.                    Value, Openmode.forread); //Delete action for groups with a group name that contains "part-" or groups with a number of 2 entities in an anonymous group                    if(PartGroup.Name.Contains ("part-") || (partgroup.isanonymous && Partgroup.numentities = =2))                    {                        //Delete the objects in the group and then delete the group, then delete the group directly.                        foreach(ObjectId IDinchPartgroup.getallentityids ()) {Entity ent=(Entity) ID.                            GetObject (Openmode.forwrite); Ent.                            Erase (); Ent.                        Dispose ();                        } partgroup.upgradeopen (); Partgroup.erase (true);                    Partgroup.downgradeopen (); }                }                #endregionDelete a group#regionDelete dimension linestypedvaluelist Values=Newtypedvaluelist (); Values. ADD (0,typeof(Dimension).                Name); Selectionfilter Filter=NewSelectionfilter (values); Promptselectionresult PSR=ed.                SelectAll (filter); if(PSR. Status = =Promptstatus.ok) {//Application.showalertdialog (String. Format ("The selected dimension line has {0}!") ", PSR. Value.count));                    foreach(ObjectId IDinchPSR. Value.getobjectids ()) {Entity ent=(Dimension) ID.                        GetObject (Openmode.forwrite); Ent.                        Erase (); Ent.                    Dispose (); }                }                #endregionDelete dimension linesTrans.commit (); }        }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.