View Full Version : vb.net - dxf issue
robtemp
2012-02-21, 08:00 PM
I've got a vb.net program that reads coordinates in from an excel file. It places blocks (dwg file) that are called into autocad at the coordinates read from the excel file.
The program appeared to function well until I stumbled across an issue with the generated autocad drawing. Once the program is complete and all the blocks are drawn in autocad I can save the file as a .dwg file and open it again without issue. The problem I'm having is when I save the file as a .dxf file (2000, or 2007 version) and try to open it again in autocad, I'll get a message like the following:
Error in BLOCK_RECORD Table
Invalid symbol table record name: "" on line 1824.
Invalid or incomplete DXF input -- drawing discarded
I really don't even know where to start looking to resolve this. Why would the .dwg file be fine (or so it appears) but the .dxf file has this issue??
Thanks,
Rob
dgorsman
2012-02-21, 08:10 PM
Does the DWG file pass a call to AUDIT?
robtemp
2012-02-21, 09:30 PM
Does the DWG file pass a call to AUDIT?
I don't really know what "AUDIT" is. :Oops: I would assume not.
Ed Jobe
2012-02-21, 11:00 PM
AUDIT is a command that checks the dwg file for errors. Its under Drawing Utilities menu in the Quick Access Toolbar. You may not be inserting the blocks properly or one of the blocks has issues. The AUDIT command should tell you which one.
robtemp
2012-02-21, 11:51 PM
Thanks for the help guys.
After auditing the generated drawing in autocad the "errors" were all fixed and I was able to save and open the dxf without issue.
I notice that if I list one of the blocks inserted into Autocad prior to running the audit command the block name is an empty string. After running the audit command the block names are assigned "audit......" which apparently fixes the issue.
Inserting this same drawing using VBA, assigned the file name as the block name by default. That's not the case with vb.net.
Now I have to figure out how to send the audit command via vb.net.
Application.AcadApplication.audit() doesn't seem to do anything.
dgorsman
2012-02-22, 12:00 AM
I usually recommend to my users to run AUDIT at least once a day on every drawing they open, either right after opening or right before closing. Keeps the roaches from multiplying too far out of control so they can be stepped on rather than calling the exterminator. :mrgreen:
I wouldn't count on an AUDIT to fix these, but rather fix the originating problem instead. Perhaps the block name you are passing is getting reset/not set or throwing a error thats not being caught?
Now I have to figure out how to send the audit command via vb.net.
Application.AcadApplication.audit() doesn't seem to do anything.
Try to use Sendcommand in seperate Sub
Dim cmd As String = String.Format("_audit{0}N{0}", " ")
doc.SendStringToExecute(cmd, False, False, False)
~'J'~
Kerry Brown
2012-02-22, 09:03 AM
Error in BLOCK_RECORD Table
Invalid symbol table record name: "" on line 1824.
Invalid or incomplete DXF input -- drawing discarded
I really don't even know where to start looking to resolve this. Why would the .dwg file be fine (or so it appears) but the .dxf file has this issue??
Thanks,
Rob
Open the DXF file in a text editor ..navigate to the nominated line ( 1824 in the example)
You'll find that a block probably does not have a name .. ie ""
I'm surprised that the runtime does not spit the dummy at you.
Without seeing your code we're guessing.
Perhaps you need to set come exception handling that has a neaningful statement in the catch segment.
Have you tried to debug the code and stepping through the operations.
Can you identify from the DXF file the blockRecord that is causing the error ?
robtemp
2012-02-22, 06:00 PM
Try to use Sendcommand in seperate Sub
Dim cmd As String = String.Format("_audit{0}N{0}", " ")
doc.SendStringToExecute(cmd, False, False, False)
~'J'~
Thanks. I just changed the "N" to "Y" and it worked perfectly. :)
robtemp
2012-02-22, 06:49 PM
I'm not sure I know what you mean by opening a dxf with a text editor. I can use the list command in autocad to see that the blocknames are an empty string. The Audit command assigns a name to the blocknames.
So how can I assign the blockname? I tried to assign a block name but it's a readonly property. My VBA macro assigned the blockname as the file name without any added code on my part.
One thing I probably need to change with my code is that for each line of data it reads from excel it calls my Insertblock routine which goes through the entire transaction..blocktable creation etc.. each time.
Open the DXF file in a text editor ..navigate to the nominated line ( 1824 in the example)
You'll find that a block probably does not have a name .. ie ""
I'm surprised that the runtime does not spit the dummy at you.
Without seeing your code we're guessing.
Perhaps you need to set come exception handling that has a neaningful statement in the catch segment.
Have you tried to debug the code and stepping through the operations.
Can you identify from the DXF file the blockRecord that is causing the error ?
Ed Jobe
2012-02-22, 06:59 PM
a dxf file is not binary, just ascii. You can open it in Notepad, a text or ascii editor. If you've worked with lisp dxf codes, you should be able to read the file.
A block should never be missing a name. If it does, your block got corrupted or you're missing something in your code, i.e. creating one from scratch and forgetting to assign a name. Using the BLOCK command, if you typed a name that already exists, you get an error notice. Think what would happen if all blocks used and empty string for a block name.
dgorsman
2012-02-22, 07:35 PM
Right, a block definition always has a name. A quick check of the ol' ActiveX CHM documentation shows the signature of the method called to add a new Block to the Blocks collection requires a name argument. There should be a similar process for managed dotNET when adding to the BlockTable.
robtemp
2012-02-23, 12:20 AM
Ed,
My block is an existing autocad drawing with attributes. I"m not creating one from scratch.
a dxf file is not binary, just ascii. You can open it in Notepad, a text or ascii editor. If you've worked with lisp dxf codes, you should be able to read the file.
A block should never be missing a name. If it does, your block got corrupted or you're missing something in your code, i.e. creating one from scratch and forgetting to assign a name. Using the BLOCK command, if you typed a name that already exists, you get an error notice. Think what would happen if all blocks used and empty string for a block name.
Ed Jobe
2012-02-23, 03:34 PM
That was just an example I gave. Not much else we can do but guess without seeing any of your code. But the main point is, you can't have a block without a name. You have to start debugging. If you are inserting an existing file as a block, how did it get into your host dwg without a name assigned to the block table record?
robtemp
2012-02-23, 05:19 PM
Thanks Ed.
It looks like the problem with my code was here:
BlkId = myDB.Insert(BlockDescription, db, True)
I was originally passing a string of the blocks entire file path (C:\temp\etc...) to "BlockDescription" which it apparently didn't like. I'm now passing it a much shorter string and the problem seems to have disapeared.
Thanks for everyone's help.
Rob
Ed Jobe
2012-02-23, 08:52 PM
You might want to add a check to verify legal block names.
// Check whether it works as a symbol table name.
// Validates name and any invalid characters are replaced.
BlockName = SymbolUtilityServices.RepairSymbolName(BlockName, false);
norman.yuan
2012-02-23, 11:15 PM
As you have already found out, when you insert the block into drawing, your specified Block Name may contain invalid character, such as "\".
It is known that when Database.Insert() is called, if the BlockName parameter contains invalid character, ACAD API did not raise an exception, it simply goes ahead with the insertion and make the inserted block (definition) with empty name.
There is a post in AutoCAD forum:
http://forums.autodesk.com/t5/NET/Block-insertion-has-no-name-in-VB-net/m-p/3289483/highlight/true#M26777
So, it is the programmer's responsibility to make sure the block name specified in Database.Insert() is valid.
Ed Jobe
2012-02-24, 04:02 PM
Welcome to AUGI Norman.
robtemp
2012-02-24, 06:16 PM
Thanks Norman for this info!! :)
As you have already found out, when you insert the block into drawing, your specified Block Name may contain invalid character, such as "\".
It is known that when Database.Insert() is called, if the BlockName parameter contains invalid character, ACAD API did not raise an exception, it simply goes ahead with the insertion and make the inserted block (definition) with empty name.
There is a post in AutoCAD forum:
http://forums.autodesk.com/t5/NET/Block-insertion-has-no-name-in-VB-net/m-p/3289483/highlight/true#M26777
So, it is the programmer's responsibility to make sure the block name specified in Database.Insert() is valid.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.