Author Topic: ReadDwgFile method fails  (Read 6635 times)

0 Members and 1 Guest are viewing this topic.

Nathan Taylor

  • Guest
ReadDwgFile method fails
« on: January 14, 2007, 08:49:50 PM »
Has anyone noticed that the ReadDwgFile method seems to fail when there is an underscore in the drawing name? Underscores in the path are ok.

The following works without error.
Code: [Select]
Dim objBlockDefDB As Database = New Database
objBlockDefDB.ReadDwgFile("Z:\RAA_UTIL07\symbols\Regional\TBSHIELD.dwg", IO.FileShare.ReadWrite, False, "")
Dim strTempName As String = "TempBlockDef" & "-" & DateTime.Now.ToString
Dim objTempBlockDefId As ObjectId = objDB.Insert(strTempName, objBlockDefDB, True)
If I change the file name to a drawing named with an underscore I get Autodesk.AutoCAD.Runtime.Exception: ePermanentlyErased on the last line.

Regards - Nathan

Nathan Taylor

  • Guest
Re: ReadDwgFile method fails
« Reply #1 on: January 15, 2007, 12:09:12 AM »
Has anyone noticed that the ReadDwgFile method seems to fail when there is an underscore in the drawing name? Underscores in the path are ok.

The following works without error.
Code: [Select]
Dim objBlockDefDB As Database = New Database
objBlockDefDB.ReadDwgFile("Z:\RAA_UTIL07\symbols\Regional\TBSHIELD.dwg", IO.FileShare.ReadWrite, False, "")
Dim strTempName As String = "TempBlockDef" & "-" & DateTime.Now.ToString
Dim objTempBlockDefId As ObjectId = objDB.Insert(strTempName, objBlockDefDB, True)
If I change the file name to a drawing named with an underscore I get Autodesk.AutoCAD.Runtime.Exception: ePermanentlyErased on the last line.

Regards - Nathan
If I rename the file I still get the error so I will try and work out what the real problem is.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: ReadDwgFile method fails
« Reply #2 on: January 15, 2007, 12:24:16 AM »
In your path, shouldn’t you be using something like?

Code: [Select]
“Z:\\RAA_UTIL07\\symbols\\Regional\\TBSHIELD.dwg"

Or

@"Z:\RAA_UTIL07\symbols\Regional\TBSHIELD.dwg"

Just curious

Dan

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ReadDwgFile method fails
« Reply #3 on: January 15, 2007, 01:10:02 AM »
Yep, that should fix it.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Nathan Taylor

  • Guest
Re: ReadDwgFile method fails
« Reply #4 on: January 15, 2007, 05:26:18 PM »
In your path, shouldn’t you be using something like?

Code: [Select]
“Z:\\RAA_UTIL07\\symbols\\Regional\\TBSHIELD.dwg"

Or

@"Z:\RAA_UTIL07\symbols\Regional\TBSHIELD.dwg"

Just curious

Dan

The problem isn't with the format of the path. When I had the path incorrect from memory I think I had an eFileNotFound error.
I will repost when I have solved the problem or have a better idea of what it is.

Regards - Nathan

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: ReadDwgFile method fails
« Reply #5 on: January 15, 2007, 06:01:42 PM »
What error are you getting now?
have you tried opening the file just read mode?

Dan

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: ReadDwgFile method fails
« Reply #6 on: January 15, 2007, 06:42:16 PM »
another thought,  is this a local drive?
If not have you copied the drawing file to a local drive for a quick test?

Nathan Taylor

  • Guest
Re: ReadDwgFile method fails
« Reply #7 on: January 15, 2007, 07:22:42 PM »
another thought,  is this a local drive?
If not have you copied the drawing file to a local drive for a quick test?


The problem was with the actual files. I don't know what the problem was but it was simply solved by the following.

Create new drawing.
Insert problem drawing.
Explode block.
Purge drawing.
Save over problem drawing.

I used VBA to do this over our whole symbol library.

Regards - Nathan

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ReadDwgFile method fails
« Reply #8 on: January 15, 2007, 08:26:08 PM »
Nathan, do you have custom objects in the drawings ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ReadDwgFile method fails
« Reply #9 on: January 15, 2007, 08:37:02 PM »
... and is this Vanilla Autocad
or one of the verticals ?

Which version ?
« Last Edit: January 15, 2007, 08:40:04 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Nathan Taylor

  • Guest
Re: ReadDwgFile method fails
« Reply #10 on: January 15, 2007, 08:41:23 PM »
Nathan, do you have custom objects in the drawings ?

No.

It does seem more than a coincidence though that it seemed to be only all files with an underscore in the name. Although the rectified files still have the original names.

Quote
... and it this Vanilla Autocad
or one of the verticals ?

Which version ?

Map 2007

Although I don't know what the problem was since it is rectified I am satisfied.

Regards - Nathan

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ReadDwgFile method fails
« Reply #11 on: January 15, 2007, 08:49:29 PM »
Just to clarify ..

the problem was caused by 'corrupt' drawings, not the code as such.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Nathan Taylor

  • Guest
Re: ReadDwgFile method fails
« Reply #12 on: January 15, 2007, 08:51:47 PM »
Just to clarify ..

the problem was caused by 'corrupt' drawings, not the code as such.



That seems to be the case.

dull_blades

  • Guest
Re: ReadDwgFile method fails
« Reply #13 on: March 21, 2012, 01:01:24 PM »
I know this is a very old topic, but I was having this same issue with some blocks and found this thread.  I had to do the same thing Nathan did to correct the issue (insert, explode and save over old block).

We use vanilla AutoCAD 2012 with no 3rd party apps.  The blocks are pretty old (about 6 years) and appear to have been created in AutoCAD 2004.

Have any other resolutions been discovered since this thread was created?  I really don't wish to repair our entire block library.  :cry: