Author Topic: .net clean up file  (Read 1871 times)

0 Members and 1 Guest are viewing this topic.

JONTHEPOPE

  • Guest
.net clean up file
« 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?


ChrisCarlson

  • Guest

JONTHEPOPE

  • Guest
Re: .net clean up file
« Reply #2 on: April 24, 2015, 02:05:14 PM »
cool thanks

JONTHEPOPE

  • Guest
Re: .net clean up file
« Reply #3 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
    }
}