Author Topic: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code  (Read 3621 times)

0 Members and 1 Guest are viewing this topic.

MarioR

  • Newt
  • Posts: 64
Hallo,

i have the problem:

It is running an command on Civil3D that select entities from named layers and
copy the entities with "Database.Wblock(newDB, selectedIds, ..) into newDB.
Now i will save the newDB as "PlainAutoCAD-DWG" like  the command "-EXPORTTOAUTOCAD".

But i cant using "SendStringToExecute" then the command runs after exit the c#-function
and on this time is the newDB "end Using - killed".

I have test the "http://www.theswamp.org/index.php?topic=44880.0" but into Civil
ist nothing a Proxy.

How can i detect the "evil Civil-objects"?

regards Mario
« Last Edit: March 12, 2015, 07:26:19 AM by MarioR »

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code
« Reply #1 on: March 16, 2015, 05:02:55 AM »
As a variant - you can explode and remove all proxy-objects and proxy-entities (not Civil only). Here is a screen and attached zip-file.

MarioR

  • Newt
  • Posts: 64
Re: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code
« Reply #2 on: March 18, 2015, 05:12:54 AM »
Hello Andrey,

sorry for the late reply.

Your Dll work on plain AutoCAD with a DWG create on Civil.
Command "proxy" found over 2000 proxyobjects and "rmproxy" remove that.
But the creators of the Civil-files have only Civil and on Civil with the same file
found the "proxy"-Command nothing proxy.

mmm... no wiser than i was before ...

regards Mario

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code
« Reply #3 on: March 18, 2015, 05:24:02 AM »
But the creators of the Civil-files have only Civil and on Civil with the same file
found the "proxy"-Command nothing proxy.

mmm... no wiser than i was before ...
I don't understand this your message. Of course, for AutoCAD Civil the Civil-objects are not proxy. It will be for other AutoCAD only (what is not AutoCAD Civil).
« Last Edit: March 18, 2015, 05:27:31 AM by Andrey Bushman »

MarioR

  • Newt
  • Posts: 64
Re: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code
« Reply #4 on: March 20, 2015, 11:25:18 AM »
Hello Andrey,
Quote
Of course, for AutoCAD Civil the Civil-objects are not proxy.

... that is the problem.

I must search the "AEC" (Civil) Objects and explode or delete this in running Civil
like the EXPORTTOAUTOCAD - command. But how i can detect the AEC/Civil objects
onto DWG?

regards Mario

MarioR

  • Newt
  • Posts: 64
Have found a Solution
« Reply #5 on: March 24, 2015, 06:04:48 AM »
Hello,

i have found a solution, it is perhaps not the best, but it works and plain AutoCAD read the dwg without proxyerror.

Code: [Select]
        public static Boolean cleanCivilObjects()
        {
            Boolean result = false;
            Database acDatabase = HostApplicationServices.WorkingDatabase;
            using (Transaction acTransaction = acDatabase.TransactionManager.StartTransaction())
            {
                // 1. clean Named Object Dictionary
                // Namepattern for search StartsWith
                List<String> badNamedObjPattern = new List<String>() { "{24de2741", "ade_", "aec_", "autodesk_map", "gwsundorecorder", "root" };
                List<String> deleteDictEntry = new List<String>();
                DBDictionary acNamedObjectDict = (DBDictionary)acTransaction.GetObject(acDatabase.NamedObjectsDictionaryId, OpenMode.ForWrite);
                foreach (DBDictionaryEntry acNamedItem in acNamedObjectDict)
                {
                    foreach (String namePattern in badNamedObjPattern)
                    {
                        if (acNamedItem.Key.ToLower().StartsWith(namePattern))
                        {
                            deleteDictEntry.Add(acNamedItem.Key);
                            break;
                        }
                    }
                }
                if (deleteDictEntry.Count > 0)
                {
                    foreach (String delName in deleteDictEntry)
                    {
                        acNamedObjectDict.Remove(delName);
                    }
                }
                // 2. clean RegAppTable
                // Namepattern for search StartsWith
                List<String> badNamePattern = new List<String>() { "acmap", "ade", "aecc", "acaec", "dco", "map" };
                RegAppTable acRegAppTable = (RegAppTable)transaction.GetObject(acDatabase.RegAppTableId, OpenMode.ForRead);
                ObjectIdCollection objectIdsToDelete = new ObjectIdCollection();
                foreach (ObjectId acRATRId in acRegAppTable)
                {
                    RegAppTableRecord acRegAppTableRecord = (RegAppTableRecord)acTransaction.GetObject(acRATRId, OpenMode.ForRead);
                    if (acRegAppTableRecord != null)
                    {
                        foreach (String namePattern in badNamePattern)
                        {
                            if (acRegAppTableRecord.Name.ToLower().StartsWith(namePattern))
                            {
                                if (!objectIdsToDelete.Contains(acRegAppTableRecord.Id))
                                    objectIdsToDelete.Add(acRegAppTableRecord.Id);
                                break;
                            }
                        }
                    }
                }
                // delete all Objects
                if (objectIdsToDelete.Count > 0)
                {
                    DBObject acDBObject;
                    foreach (ObjectId acObjectId in objectIdsToDelete)
                    {
                        acDBObject = acTransaction.GetObject(acObjectId, OpenMode.ForWrite);
                        acDBObject.Erase(true);
                    }
                }
                acTransaction.Commit()
                result = true;
            }
            return result;
        }


Important!
You don't save the database with "document.CloseAndSave(fileName)" this function include again the 'bad-civil-Objects'.
If you save database with "database.SaveAs(filename)" works fine.

regards
Mario
« Last Edit: March 24, 2015, 06:08:18 AM by MarioR »

BlackBox

  • King Gator
  • Posts: 3770
Re: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code
« Reply #6 on: March 25, 2015, 08:54:30 AM »
But i cant using "SendStringToExecute" then the command runs after exit the c#-function
and on this time is the newDB "end Using - killed".

This recent thread may be of use:

Editor.Command() vs Editor.CommandAsync()



Cheers
"How we think determines what we do, and what we do determines what we get."

MarioR

  • Newt
  • Posts: 64
Re: Explode/Delete Civil "Proxys" like EXPRTTOAUTOCAD on .net-Code
« Reply #7 on: March 27, 2015, 05:06:00 AM »
Hello BlackBox,

sorry i had forgotten. I must use AutoCAD/Civil 2014.

But it is nice to know, for the next versionchange.

regards Mario