marko_ribar Posted February 7, 2012 Posted February 7, 2012 (edited) Hi to all, recently I was experimenting with ObjectDBX and I've found out that I can't enable it for some extra simple tasks : So here is the problem, I want to set current layer in all dozen of dwgs to "0" layer and then make line pt1-pt2... (defun CLAYTO0+LIN ( doc adoc / 0lay msp pt1 pt2 ) (vl-load-com) (setq *lay (vla-get-layers adoc)) (vlax-for lay *lay (if (= (vla-get-name lay) "0") (setq 0lay lay)) ) (vla-put-activelayer adoc 0lay) (setq msp (vla-get-modelspace adoc)) (setq pt1 '(0.0 0.0 0.0)) (setq pt2 '(100.0 100.0 100.0)) (vla-addline msp (vlax-3d-point pt1) (vlax-3d-point pt2)) t ;; Success for layer 0 ) (defun C:TEST ( ) (LOAD (findfile "ObjectDBX Wrapper.lsp")) (LM:ODBX 'CLAYTO0+LIN nil t) ) Here was my modified ObjectDBX Wrapper.lsp witch was wrong so it was removed... I keep getting %catch-all-apply-error% and I don't quite understand why... If it is possible to do this simple tasks in other way or fix my error, please reply... Thanks, M.R. Edited February 7, 2012 by marko_ribar removed modified ObjectDBX Wrapper.lsp Quote
Lee Mac Posted February 7, 2012 Posted February 7, 2012 The 'ActiveLayer' property of the Document Object is not available when interfacing with ObjectDBX; neither are System Variable functions (such as setvar / vla-setvariable) - so you would need to use a Script to set a Layer Current in multiple drawings. Modifying my function to use the ActiveDocument Object is pointless since when using ObjectDBX you are operating on the ObjectDBX Document object not the ActiveDocument Object. I would appreciate if you removed the erroneous code. Quote
marko_ribar Posted February 7, 2012 Author Posted February 7, 2012 Lee, thanks for your reply, I was just experimenting, so I asked to see if this is possible... Too bad it isn't... Correct code can be found on your site, I don't know what should I remove - it's just my question, not revision of your code although it looks that way... Tell me, what should I remove? M.R. Quote
Lee Mac Posted February 7, 2012 Posted February 7, 2012 The modified ObjectDBX Wrapper since it may be misleading to others. Quote
marko_ribar Posted February 7, 2012 Author Posted February 7, 2012 I've solved the problem... Still can't set current layer to 0 in all dwgs, but newly created line successfully changed to "0" layer : (defun LIN-0-LAYER ( doc / msp obj ) (vl-load-com) (setq msp (vla-get-modelspace doc)) (setq obj (vla-addline msp (vlax-3d-point '(0.0 0.0 0.0)) (vlax-3d-point '(100.0 100.0 100.0)))) (vla-put-layer obj "0") t ;; Success for at least one of the objects ) (defun C:TEST ( ) (LOAD (findfile "ObjectDBX Wrapper.lsp")) (LM:ODBX 'LIN-0-LAYER nil t) ) M.R. OK., Lee now it works with your original ObjectDBX Wrapper.lsp, so I'll remove my modified version... Quote
man_not_machine Posted March 1, 2023 Posted March 1, 2023 Or you could just place this bit of code into you current AutoCAD Acaddoc.lsp (and PRINC it our once you are finished for later re-use) You could also create similar code to drawing your LINE from pt1 to pt2 (command "-LAYER" "Set" "0" "Color" "7" "" "" "-COLOR" "ByLayer" "-LINETYPE" "Set" "ByLayer" "") Quote
Steven P Posted March 1, 2023 Posted March 1, 2023 There is a fair chance that in the last 11 years the OP has solved their problem - which was quite specific and good information given out which gives the answer. Quote
man_not_machine Posted March 1, 2023 Posted March 1, 2023 True Steven P, but some else might do a Google search on this topic (which is how I found this thread). 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.