.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiline Attributes Revert to Single Line

7 REPLIES 7
Reply
Message 1 of 8
HJohn1
1191 Views, 7 Replies

Multiline Attributes Revert to Single Line

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.

7 REPLIES 7
Message 2 of 8
Anonymous
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);




Message 3 of 8
FRFR1426
in reply to: Anonymous

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)

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Tags (1)
Message 4 of 8
HJohn1
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.

Message 5 of 8
HJohn1
in reply to: HJohn1

After all this time I still having this issue coming back from time to time and screwing us up.  Sometimes there is data lost when the attributes reverts back to single line.  Has anyone experienced this issued or is just only me who is using multiline attributes? It will be great to know at least why it happens or better yet to be able to prevent it from happening. Please help. 

Message 6 of 8
ps-trigenex
in reply to: HJohn1

Hi

 

I am having the same problem. When I opened my drawing this morning, my attribute that had 3 lines has only one line. It's still a multiline when I open the blockeditor but, the data of the 2 other lines are missing. This is very worring.

 

Any solutions?

 

Thanks,

Marcelo

Message 7 of 8
KenWashburn
in reply to: ps-trigenex

I've run into this as well.  The only solution I've come up with is to use the SystemIO.File.copy to copy the old file to a new file name.  For example:

 

Dim dwgpath As String = ThisDrawing.Path

Dim originalName As String = ThisDrawing.Name

Dim cllicode As String = Left(ThisDrawing.Name, 😎

Dim flSqLc As String = Mid(ThisDrawing.Name, 13, 😎

Dim woNum As String = WOSeqForm.TextBoxYear.Text & WOSeqForm.TextBoxSeq.Text & WOSeqForm.TextBoxRev.Text

newFileName = cllicode & "-WO-" & woNum & "-" & flSqLc & ".dwg"

Dim newPath As String = ThisDrawing.Path & "\" & newFileName

Dim oldPath As String = dwgpath & "\" & originalName

Try

Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

 

 

CloseAndDiscard(acDoc)

File.Copy(oldPath, newPath)

Dim acDocMgr As DocumentCollection = Application.DocumentManager

DocumentCollectionExtension.Open(acDocMgr, newPath, False)

Catch ex As Exception

End Try

 

This gets information about the existing drawing name and info from a dialog box (WOSeqForm) to create both the oldPath and newPath.  You can use whatever you want for creating these paths.  Then it closes the drawing.  Then it uses File.Copy to create a copy of the file with a new name.  Then it opens the newly named drawing file.

Message 8 of 8
jalbert300
in reply to: HJohn1

I am also experiencing this problem. I have developed an Add-In that uses db.SaveAs quite often, and it's come to my attention that my Add-In is wrecking users blocks with multiline attributes. Not good!

 

I'm attaching a sample drawing, a link to sample DLL and a video demonstrating the issue. The steps to reproduce are:

 

  1. Open the provided "Multiline Att Test.dwg".
  2. Using NETLOAD, load the provided "SaveAsTest.dll"
  3. In command line, type "SaveAsTest" to execute the command in DLL.
  4. Next, without saving the open drawing manually, either open the DWG a second time read-only, or close the drawing(without saving) and re-open.
  5. Once drawing is open, you will notice multiline attribute in block has reverted to single line.

Sample DWG is attached, and here is link to DLL with custom SaveAsTest command.

https://app.box.com/s/y5qwhpqf1som9iac52fj2f2vzk5tz4hv

 

Please see this video showing steps from above:

 

Again, this is quite a big problem for some, and seems to have been round since 2013 at least. At the moment, I have to inform users of my Add-In they cannot use Multiline Attributes in their blocks.

 

Please help Autodesk!

 

Thanks,

 

Jon

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost