raffich Posted August 26, 2015 Share Posted August 26, 2015 Hi there i found this vba code an it works perfekt when i can use the vba. but in the office there is vba restricted and so i would like to use this in a lisp: [font=Courier New][size=2]Sub EsWerdeDunkel() Dim Entity As AcadEntity, Blockdef As AcadBlock, Blockref As AcadBlockReference For Each Entity In ThisDrawing.ModelSpace: Entity.Color = 254: Next Entity For Each Blockdef In ThisDrawing.Blocks If Blockdef.IsLayout = False Then For Each Entity In Blockdef: Entity.Color = 254: Next Entity Next Blockdef End Sub[/size][/font] maybe there is a way to choos the color by a color-promt box... hope you understand my english... i don't know how to code lisp. (i use Bricscad 14, 64Bit at office... but the lisp works the same as in Autocad) thanks 4 help raffi Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 26, 2015 Share Posted August 26, 2015 As a quick translation of your code: (defun c:test ( / col doc foo ) (if (setq col (acad_colordlg 1)) (progn (setq foo (lambda ( obj ) (if (vlax-write-enabled-p obj) (vla-put-color obj col))) doc (vla-get-activedocument (vlax-get-acad-object)) ) (vlax-map-collection (vla-get-modelspace doc) 'foo) (vlax-map-collection (vla-get-blocks doc) '(lambda ( blk ) (if (and (= :vlax-false (vla-get-islayout blk)) (= :vlax-false (vla-get-isxref blk)) ) (vlax-map-collection blk 'foo) ) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
raffich Posted August 27, 2015 Author Share Posted August 27, 2015 hi Lee Mac not working... there is an error: Loading D:\_Witzig\_Admin\CAD\LISP\Farbe.lsp : (LOAD "D:/_Witzig/_Admin/CAD/LISP/Farbe.lsp")C:TEST : TEST ; ----- LISP : Call Stack ----- ; [0]...C:TEST <<-- ; ; ----- Error around expression ----- 'FOO ; ; error : no function definition <FOO> ; expected FUNCTION at [sYMBOL-FUNCTION] the color selection works but after the error stop the script... Quote Link to comment Share on other sites More sharing options...
raffich Posted August 27, 2015 Author Share Posted August 27, 2015 Yess... found it! (defun c:test ( / col doc foo ) (if (setq col (acad_colordlg 1)) (progn (setq foo (lambda ( obj ) (if (vlax-write-enabled-p obj) (vla-put-color obj col))) doc (vla-get-activedocument (vlax-get-acad-object)) ) (vlax-map-collection (vla-get-modelspace doc) foo) (vlax-map-collection (vla-get-blocks doc) '(lambda ( blk ) (if (and (= :vlax-false (vla-get-islayout blk)) (= :vlax-false (vla-get-isxref blk)) ) (vlax-map-collection blk foo) ) ) ) ) ) (princ) ) the 'foo was the mistake! now it works...! many thanks! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 27, 2015 Share Posted August 27, 2015 hi Lee Mac not working... there is an error: Loading D:\_Witzig\_Admin\CAD\LISP\Farbe.lsp : (LOAD "D:/_Witzig/_Admin/CAD/LISP/Farbe.lsp")C:TEST : TEST ; ----- LISP : Call Stack ----- ; [0]...C:TEST <<-- ; ; ----- Error around expression ----- 'FOO ; ; error : no function definition <FOO> ; expected FUNCTION at [sYMBOL-FUNCTION] the color selection works but after the error stop the script... This looks to be a bug with the vlax-map-collection implementation in BricsCAD - the code I have posted performs fine in AutoCAD. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted September 2, 2015 Share Posted September 2, 2015 As a quick translation of your code: (defun c:test ( / col doc foo ) (if (setq col (acad_colordlg 1)) (progn (setq foo (lambda ( obj ) (if (vlax-write-enabled-p obj) (vla-put-color obj col))) doc (vla-get-activedocument (vlax-get-acad-object)) ) (vlax-map-collection (vla-get-modelspace doc) 'foo) (vlax-map-collection (vla-get-blocks doc) '(lambda ( blk ) (if (and (= :vlax-false (vla-get-islayout blk)) (= :vlax-false (vla-get-isxref blk)) ) (vlax-map-collection blk 'foo) ) ) ) ) ) (princ) ) Hi Lee. Is this any different from ColorX by VVA? http://www.cadtutor.net/forum/showthread.php?533-Lisp-colour-change-for-all-layers-and-blocks&p=221559&viewfull=1#post221559 It seem to change all my blocks & nested blocks alot faster than ColorX (except the leader lines still retain color its grey colour) Thanks Quote Link to comment Share on other sites More sharing options...
vernonlee Posted September 3, 2015 Share Posted September 3, 2015 Hi Lee. Is this any different from ColorX by VVA? http://www.cadtutor.net/forum/showthread.php?533-Lisp-colour-change-for-all-layers-and-blocks&p=221559&viewfull=1#post221559 It seem to change all my blocks & nested blocks alot faster than ColorX (except the leader lines still retain color its grey colour) Thanks Anyone know? Quote Link to comment Share on other sites More sharing options...
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.