TheSwamp

Code Red => .NET => Topic started by: JONTHEPOPE on April 24, 2015, 01:42:01 PM

Title: .net clean up file
Post by: JONTHEPOPE on April 24, 2015, 01:42:01 PM
Hi Everyone,

 I'm looking to write a program that takes a drawing and cleans it up by purging it and deleting all the dimension also I wanted to change all the layers to colour 8? except 0 >>> scary right?

Title: Re: .net clean up file
Post by: ChrisCarlson on April 24, 2015, 01:44:42 PM
Have you looked at the exchange?

https://apps.exchange.autodesk.com/ACD/en/List/Search?searchboxstore=ACD&facet=&collection=&sort=dateUpdated%2Cdesc&language=en&query=Purge
Title: Re: .net clean up file
Post by: JONTHEPOPE on April 24, 2015, 02:05:14 PM
cool thanks
Title: Re: .net clean up file
Post by: JONTHEPOPE on May 08, 2015, 06:46:58 PM
This is what I was looking for.
found it in help under select objects in the drawing area.
now to figure out how to bind and purge

Code: [Select]
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
 
[CommandMethod("SelectObjectsOnscreen")]
public static void SelectObjectsOnscreen()
{
    // Get the current document and database
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
    Database acCurDb = acDoc.Database;

    // Start a transaction
    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
    {
        // Request for objects to be selected in the drawing area
        PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

        // If the prompt status is OK, objects were selected
        if (acSSPrompt.Status == PromptStatus.OK)
        {
            SelectionSet acSSet = acSSPrompt.Value;

            // Step through the objects in the selection set
            foreach (SelectedObject acSSObj in acSSet)
            {
                // Check to make sure a valid SelectedObject object was returned
                if (acSSObj != null)
                {
                    // Open the selected object for write
                    Entity acEnt = acTrans.GetObject(acSSObj.ObjectId,
                                                        OpenMode.ForWrite) as Entity;

                    if (acEnt != null)
                    {
                        // Change the object's color to Green
                        acEnt.ColorIndex = 3;
                    }
                }
            }

            // Save the new object to the database
            acTrans.Commit();
        }

        // Dispose of the transaction
    }
}