Rename Layout Name - SheetSet Manager API

Rename Layout Name - SheetSet Manager API

edfdiloreto
Contributor Contributor
854 Views
8 Replies
Message 1 of 9

Rename Layout Name - SheetSet Manager API

edfdiloreto
Contributor
Contributor

I'm trying to rename the sheet layout name using the API. I wanto to rename the layout name (see image)

 

Layout Name.png

 

 

I have the following code, but it's not working.

 

// Locking DB here
string layoutName = "My new Layout Name";
AcSmSheet sheet = (AcSmSheet)_sheetId.GetPersistObject(); 
sheet.GetLayout().SetName(layoutName);
// Unlocking DB here

 

I'm using the correct method to set the new name? The code runs without any errors but the name is not changed.

0 Likes
Accepted solutions (1)
855 Views
8 Replies
Replies (8)
Message 2 of 9

hippe013
Advisor
Advisor

I don't have the full picture of your code so I shooting in the dark here, but would the following have anything to do with your issue? 

 

"In order to make changes to a database, it must be locked using the LockDb method. Any changes you make can be saved or rolled back using the UnlockDb method. UnlockDb has a Boolean commit parameter that controls this behavior. If the value of the commit parameter is true, then the changes will be written to the file. If you pass in false for the commit parameter, the changes will be rolled back or undone by reloading the database from disk."

0 Likes
Message 3 of 9

edfdiloreto
Contributor
Contributor

@hippe013  Thanks for your response. I'm using the unlock method with the parameter set to true.

 

 

0 Likes
Message 4 of 9

hippe013
Advisor
Advisor

In looking more into it. 

 

AcSmAcDbLayoutReference.SetName Method

 

Sets the name of the referenced object.

 

"Input string containing the name of a symbol table record or dictionary entry"

 

I don't believe that this method is for renaming the layout. 

0 Likes
Message 5 of 9

edfdiloreto
Contributor
Contributor

If that is the case, it's very confusing!

0 Likes
Message 6 of 9

hippe013
Advisor
Advisor

@edfdiloreto 

 

Well, yes and no. I don't know what the context is of what you are trying do. However, you are using the Sheetset Manager API. This is working with .dst files of the Sheetset which references the layouts of drawings. It seems strange to me to want to change the layout name from the context of working with sheet sets and not the other way around. Changing the name of the layout would be done from the context of working with the actual source drawing database. There are many examples on here for changing the name of the layout. 

0 Likes
Message 7 of 9

hippe013
Advisor
Advisor
Accepted solution

@edfdiloreto 

 

A quick example of renaming a layout

Sorry for VB, it's what I use. 

 

Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

Dim key As String = "Layout1"

Using tr As Transaction = db.TransactionManager.StartTransaction
    Dim dLayouts As DBDictionary = tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead)

    If dLayouts.Contains(key) Then
        Dim layout As Layout = tr.GetObject(dLayouts(key), OpenMode.ForWrite)
        layout.LayoutName = "My Renamed Layout1"
        ed.Regen()
    End If

    tr.Commit()
End Using

 

Message 8 of 9

edfdiloreto
Contributor
Contributor

Great, I'll use the standard Autocad .NET API then. I thought it was more straightforward to do it from the SSM API.

0 Likes
Message 9 of 9

hippe013
Advisor
Advisor

I am happy I was able to help.

 

0 Likes