Adding a new layer will remove previous layer automatically

Adding a new layer will remove previous layer automatically

Anonymous
Not applicable
748 Views
2 Replies
Message 1 of 3

Adding a new layer will remove previous layer automatically

Anonymous
Not applicable

Hi All,

 

I have a customized app developed for AutoCad 2012(using acmgd.dll and acdbmgd.dll). As part of a ReBuild Dwg feature, I'm trying to erase all the entities and layers from the working DB and recreate all of them again.

Steps:

1. Erase all the existing layers and objects from the database.

2. Create all the layers again and add the objects to the layers programatically as shown below.

                 Using ltr As LayerTableRecord = New LayerTableRecord()
                        ltr.Name = LayerName
                        ltr.Color = AePlan.AutoCAD.CAcadColor.WindowsColor2AcadColor(LayerWindowsColor)
                        lt.UpgradeOpen()
                        layerId = lt.Add(ltr)
                        trans.AddNewlyCreatedDBObject(ltr, True)
                  End Using

 

This function works fine till creation of 3 to 4 layers. But during the creation of 5th layer(after executing layerId = lt.Add(ltr)), very strangely one of the previously created layers will be removed randomly from the database.

 

Example: lt.Has(1st Layer) returns false and also lt.Item(1st layer name) throws exception

 

This is very annoying as my rebuild dwg feature has snowball effect and fails miserably due to this unexpected behavior. I tried all over the internet but couldn't find a solution. Any help or suggestion is galdly welcomed.

 

Thanks in advance,

Prashanth

0 Likes
749 Views
2 Replies
Replies (2)
Message 2 of 3

SENL1362
Advisor
Advisor
There is no simple answer to you're question because of the limited code given.
But wouldn't it be easier to build (drawing/Database) from scratch, instead of RE-buiding?

Message 3 of 3

Anonymous
Not applicable
i could not understand why you have so strange idea. forgive me , i'd like to say,it's insane...
it is not so hard to erase all entities and layers(exclude layer 0) in a datbase, but, how can you rebuild all the entities? this would be the most difficult part of you code. doubt that you can handle it.
so, why don't you just create a blank database and copy the entities of original database into the new one? during the copy, you can modify the attributes of these entities.
0 Likes