.NET

Reply
Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 1 of 4 (255 Views)

Multiline Attributes Revert to Single Line

255 Views, 3 Replies
11-12-2013 11:07 AM

There was a discussion about this issue in the past, but there was not a clear response.  I am experiencing this issue every now and then and I don't know why or how it happens.  No modifications to the BlockDefinitions or any BlockReferences are made and for some magic all multiline attributes in the drawing file revert to single line.  After that happens the only way I know to fix them is to go through all definitions in the Block Attribute Manager and make every attribute multiline again.  This is very annoying because I don't know how it happens so it can be prevented and because it takes time to fix them again.  AutoCAD 2012 vanilla, (Mechanical) on Windows 7 32 and 64 bits.  Does anybody know what causes this issue or have any suggestions about preventing this.  Any help will be greatly appreciated.

Member
Sfinks7s
Posts: 5
Registered: ‎06-19-2013
Message 2 of 4 (205 Views)

Re: Multiline Attributes Revert to Single Line

12-02-2013 01:13 PM in reply to: HJohn1

Good evening,

I ran into the same problem in AutoCAD Architecture 2013.


1) How are you is a created multiline attribute?
2) How are you is save this drawing?

In my case I incorrect to save drawing.
Сorrected by this method:   "acDoc.Database.CloseInput(true)";

Document acDoc = Application.DocumentManager.MdiActiveDocument;
            string strDwgName = acDoc.Name;
            acDoc.Database.CloseInput(true);
            acDoc.Database.SaveAs(strDwgName, true, DwgVersion.Current, acDoc.Database.SecurityParameters);




Valued Contributor
FRFR1426
Posts: 75
Registered: ‎04-05-2012
Message 3 of 4 (179 Views)

Re: Multiline Attributes Revert to Single Line

12-18-2013 01:34 AM in reply to: Sfinks7s

Same problem here on AutoCAD 2014 (I.18.0.0). The code to reproduce:

 

[CommandMethod("DBSAVEAS", CommandFlags.Session)]
public void DbSaveAs()
{
    Document doc = Application.DocumentManager.Open(Path.Combine(Path.GetTempPath(), "dbsaveas.dwg"), false);
    Database db = doc.Database;
    db.SaveAs(db.Filename, true, db.OriginalFileVersion, db.SecurityParameters);
}

The dbsaveas.dwg is attached. It contains one block insert with a multiline attibute called title. When I launch the command above and I reopen the drawing, the multiline flag is lost on the attribute and the second line of the value disappear.

 

Tried with CloseInput: 

 

[CommandMethod("DBSAVEASCI", CommandFlags.Session)]
public void DbSaveAsWithCloseInput()
{
    Document doc = Application.DocumentManager.Open(Path.Combine(Path.GetTempPath(), "dbsaveas.dwg"), false);
    Database db = doc.Database;
    db.CloseInput(true);
    db.SaveAs(db.Filename, true, db.OriginalFileVersion, db.SecurityParameters);
}

Doesn't work. The multiline attribute revert to a single line.

 

Tried with AcadDocument.Save (COM):

 

[CommandMethod("COMSAVE", CommandFlags.Session)]
public void ComSave()
{
    Document doc = Application.DocumentManager.Open(Path.Combine(Path.GetTempPath(), "dbsaveas.dwg"), false);
    dynamic acadDoc = doc.GetAcadDocument();
    acadDoc.Save();
}

It works.

 

Tried with a side database:

 

[CommandMethod("SIDEDB", CommandFlags.Session)]
public void SideDb()
{
    using (var db = new Database(false, true))
    {
        db.ReadDwgFile(Path.Combine(Path.GetTempPath(), "dbsaveas.dwg"), FileOpenMode.OpenForReadAndReadShare, true, null);
        db.SaveAs(db.Filename, true, db.OriginalFileVersion, db.SecurityParameters);
    }
}

It works.

 

This is a really annoying bug, as it causes data lost. And I don't understand why there is no Document.Save in the .NET API (there is one in COM ???).

 

The problem also occurs with doc.DowngradeDocOpen(true)

Distinguished Contributor
HJohn1
Posts: 170
Registered: ‎09-26-2008
Message 4 of 4 (144 Views)

Re: Multiline Attributes Revert to Single Line

12-20-2013 06:38 AM in reply to: FRFR1426

I still dealing with this issue in AutoCAD 2012However, I was hopping that when we upgrade to 2014 next year, this issue will be gone but I now see that it still there.  I am not using any of the method you mentioned. I am using the following methods.

Autodesk.AutoCAD.ApplicationServices.DocumentExtension.CloseAndSave()
Autodesk.AutoCAD.ApplicationServices.DocumentExtension.CloseAndDiscard()

 

 

 

Reverting back to single line not always occurs and I have not been able to figure out when or how it happens.

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.