i will get custom block in a .dwg file from a list of blocks which I will parse programmatically in Java.
-
Have you tried anything? Stack Overflow will not write your program for you. – nkorth Aug 10 '15 at 09:00
-
i would suppose the answer to be similar to a one line command... example "LISTALLBLOCK" or "GETALLBLOCKNAME"... thanks for pointing out that StackOverflow does not help me code though... – user3336544 Aug 10 '15 at 09:25
-
For a better chance of having your question answered, at least add to your question something like `I looked at the documentation [link to documentation here] and couldn't find a way to do this.` – nkorth Aug 10 '15 at 09:33
-
Java? No, unless you call an AutoCAD instance via COM but I don't think the core console works with COM and I never intend to find out. C# - yes, Lisp - yes. but @Maxence's answer is the easiest one in this case. – CAD bloke Aug 20 '15 at 23:12
2 Answers
You can use the command INSERT with the option ?
cd C:\Program Files\Autodesk\AutoCAD 2016
accoreconsole.exe /i "Sample\Database Connectivity\Floor Plan Sample.dwg"
Command: _INSERT
Enter block name or [?]: ?
Enter block(s) to list <*>:
Defined blocks.
"CHAIR7"
"COMPUTER"
"DESK2"
"DESK3"
"DOOR"
"DR-36"
"DR-69P"
"DR-72P"
"FC15X27A"
"FC42X18D"
"FNPHONE"
"IBMAT"
"KEYBOARD"
"NCL-HL"
"RECTANG"
"RMNUM"
"SOFA2"
User Unnamed
Blocks Blocks
17 0

- 12,868
- 5
- 57
- 69
I am not familiar with Core Console
but for listing all block in a DWG
file, you need to use LISP
s. Something like axBlock
from jtbworld . You may also mock around with LISP code and call it via a SCRIPT
.
Edit:
Copy and paste following code in Notepad
and save it as axBlock.lsp
in the root fo your C
drive (for instance):
(defun c:axblocks (/ b bn tl)
(vlax-for b (vla-get-blocks
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (= (vla-get-islayout b) :vlax-false)
(setq tl (cons (vla-get-name b) tl))
)
)
(reverse tl)
)
I just tweaked jtbworld's code a little bit to make it easier for you.
Now you have your LISP code ready and you only need to load it into AutoCAD. You have couple of options for that:
- Use APPLOAD command in AutoCAD and browse for
axBlock.lsp
which you just created - Drag
axBlock.lsp
over your AutoCAD window. Call
axBlock.lsp
via a script file. And scripts are nothing really but a simple textual file with*.scr
extension. For that you just need this line of code to be in your script file:(load "C:\\axBlock.lsp")
After doing any of above three methods, as long as you type axBlock
in AutoCAD and hit Enter
, you will see the list of existing blocks.
Moreover, if you followed approach no.3 from above list, you can make a shortcut and call axBlock
within the script file as well i.e. you load and call the function in one hit. If you want to do so, just add axBlock
in the second line of your script code. Note there an extra SPACE
after axBlock

- 571
- 1
- 4
- 23
-
AutoCAD does no have much functionality on it's CoreConsole... however can u point me in the right direction on how to run .lsp scripts in a SCRIPT file?? – user3336544 Aug 11 '15 at 08:15
-
@user3336544 read my edited answer. I added more description to it. – Bababarghi Aug 11 '15 at 12:31
-
I did everything on Number 3 but the console just re-prints each line and quits... this method is the most useful to me but i can't get it to work.. – user3336544 Aug 12 '15 at 11:19
-
@user3336544 I need to see some screenshot in order to be able to help you further. – Bababarghi Aug 12 '15 at 12:52
-
turns out Visual Lisps does not work on the Core Console..... and the best way would be to call a script that calls a lisp routine on acad.exe... ex: acad.exe C:\
\ my_autocad_file.dwg /b call_attout_routine.scr – user3336544 Aug 21 '15 at 13:58