Lee Mac Posted October 15, 2010 Posted October 15, 2010 Thank you all for the help. I will be away most of the day working on some other diagrams for work. I just wanted to let you know I have received everything. I have a quick question though, am I supposed to put that other code into Lee's? Just curious. My code will (should) function correctly without any modification - the error about which Se7en commented had been fixed in my post #15 Quote
Agent 31 Posted October 15, 2010 Author Posted October 15, 2010 I am assuming the block is not in a Autocad search path so it cannot find it. I think all you need to do is to write block out the block to an Autocad search path (or make your own in options, Files tab, search file support path). This will make autocad search your drawing and when it does not find it there it should look in the search paths for Autocad and the ones you can create. Hope this helps Well the problem with that, the block IS in the support path. I keep the all of my LISPs for work and their associated files (dwgs, dcls, etc...) under the support path. Thats why I can not figure this out. I am about to try Lee's code though, I will probably respond soon to let everyone know how it works out. Wish me luck! Quote
Agent 31 Posted October 15, 2010 Author Posted October 15, 2010 Lee, Thank you greatly for the routine you sent out to me. I was quite impressed that you rewrote the entire thing and extremely quickly. I trust you have much experience on this. On that note, do you know of a good reference book I could pick up? I found a few on Amazon, but am unsure what would be good. Anyone who sees this, feel free to chime in or point me to an appropriate thread, =) I have posted below, however, the code I worked with on Lee's. I ran it as is, editing the block definitions, different variations, etc... Below are the common errors I keep receiving no matter what I do. Any ideas? xblock Block terminal references itself ; error: misplaced dot on input The part of the code in question; (defun LM:ForceBlockDefinition ( block / path ext base ) ;; © Lee Mac 2010 (setq path (C:\\Program Files\\AutoCAD 2010\\Support) ext (.dwg) base (terminal)) Quote
Se7en Posted October 15, 2010 Posted October 15, 2010 Well from what i can see you are using Lee's function wrong; The function accepts an argument. Sorry, i cant help more then that; I dont really understand Lee's code. EDIT: Should be more specific. this is wrong. (setq path (C:\\Program Files\\AutoCAD 2010\\Support) ext (.dwg) base (terminal)) Use like this: (LM:ForceBlockDefinition "C:\\Program Files\\AutoCAD 2010\\Support\\terminal.dwg") Quote
Lee Mac Posted October 16, 2010 Posted October 16, 2010 Agent, are you using the code I attached? If so there should be no need for modification. As for the earlier subfunction I posted, as Se7en correctly points out, the function is not to be modified, but rather takes arguments (as any other LISP function would). I have engineered the function to accept any form of the block as an input, i.e. "block" or "block.dwg" or "C:\\Folder\\block.dwg". May I ask why you would want to modify the subfunction - does my attached code error? Quote
Agent 31 Posted October 18, 2010 Author Posted October 18, 2010 When I use Lee's code without any modification, this is what comes up. Command: (load"xblock") LM:FORCEBLOCKDEFINITION Command: xblock Block terminal references itself *Invalid* When I use Se7en's modification, this is the error I come up with. Command: (load"xblock") ; error: syntax error Command: xblock Block terminal references itself *Invalid* And in case you are wondering, yes I changed the name to fit the macros I already have set in place, though I did leave all identifications that links it to Lee. Any ideas? Quote
Lee Mac Posted October 18, 2010 Posted October 18, 2010 Hi Agent, This is not due to the code, but because of your block. This usually happens if you have a block saved within a drawing of the same name, i.e. you have a block called 'terminal' in a drawing called 'terminal.dwg' and then you are trying to insert the drawing 'terminal.dwg' into another drawing, causing the error. The Solution: check for the above case, if so - explode & purge the block definition out of the 'terminal.dwg' and retry the code. Quote
asos2000 Posted October 25, 2010 Posted October 25, 2010 This version no need for cad file this subroutine create a layer called Point and block called Terminal Add this line at first of lisp (defun C:XBLOCK ( / ) ;WHAT DOES "(/ souk)" MEAN? [color=red](TerminalBlock)[/color] (setup) (getboxinput) And add this subroutine at end of lisp (defun TerminalBlock () (if (not (tblsearch "LAYER" "Point")) (progn (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 "Point") ;layer name (cons 62 2) ;layer color '(70 . 0) ; on, unlocked, thawed )))) (if (not (tblsearch "BLOCK" "Point")) (progn (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference") (2 . "Terminal") (10 0.0 0.0 0.0) (70 . 0))) (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "POINT") (62 . 2) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "ANSI31") (70 . 0) (71 . 0) (91 . 1) (92 . 7) (72 . 1) (73 . 1) (93 . 2) (10 -0.06285 0.0 0.0) (42 . 1.0) (10 0.06285 0.0 0.0) (42 . 1.0) (97 . 0) (75 . 0) (76 . 1) (52 . 0.0) (41 . 0.03125) (77 . 0) (78 . 1) (53 . 0.785398163397448) (43 . 0.0) (44 . 0.0) (45 . -0.00276213586401) (46 . 0.00276213586401) (79 . 0) (47 . 0.000519971032496) (98 . 1) (10 0.001298342685957 0.002354605870909 0.0))) (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (67 . 0) (8 . "POINT") (62 . 2) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 0.06285))) (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0"))) ) ) (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.