loudy000 Posted November 3, 2016 Share Posted November 3, 2016 Is there anything particular about the drawings being skipped? i.e. Is it always the same drawings that are skipped? Are the drawings particularly large? Do you receive any errors at the command-line? (you will need to enable command-line logging to view this). hi lee i've noticed that it's on the same drawings. it just open and nothing change. Never happened in large drawings. Just random Quote Link to comment Share on other sites More sharing options...
Flip Flop Posted March 18, 2021 Share Posted March 18, 2021 (edited) This looks really useful but relies on the creation of .SCR files which, on our corporate locked-down laptops, is forbidden. Is there any way of removing the dependency on .SCR files? Or is there any way of getting AutoCAD to run a script saved as a .TXT file? Thanks Edited March 18, 2021 by Flip Flop Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 21, 2021 Author Share Posted March 21, 2021 Unfortunately the AutoCAD SCRIPT command will only accept .scr files, and I'm not aware of a way to circumvent this restriction. The program could be written to update attribute values using ObjectDBX (similar to my old Global Attribute Editor), but this introduces a host of other issues such as misalignment for non-left justified attributes, restrictions on save format, and missing drawing thumbnails - consequently, I opted to abandon the use of ObjectDBX when developing this application. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 22, 2021 Share Posted March 22, 2021 (edited) Flip flop are you saying you can not make a file.txt then rename it file.scr then run script ? There are many fast ways around writing a script file. I having been doing for like 40 years. If you have a sample scr file then as a template there would be ways of creating a new scr. I use Word and excel to make scripts as they have good search replace copy options. You may have to resort to a more semi manual make a script. Lee's code is great for me a manual version would be Open dwg1 (load "chgmyatts")(chgmyatts "Tagname" "Value") close Y Open dwg2 (load "chgmyatts")(chgmyatts "Tagname2" "Value2") close Y Open dwg3 (load "chgmyatts")(chgmyatts "Tagname3" "Value3") close Y Edited March 22, 2021 by BIGAL Quote Link to comment Share on other sites More sharing options...
rlx Posted March 22, 2021 Share Posted March 22, 2021 (edited) no OP says Quote This looks really useful but relies on the creation of .SCR files which, on our corporate locked-down laptops, is forbidden. so he can't use scripts. One way around this is to erase all & purge current drawing , insert target drawing (if only model space is needed) , run lisp and saveas target and repeat for all target drawings. If layouts are needed import (or steal) them. That way lisp never looses focus. Not as fast as odbx but faster than script. Edited March 22, 2021 by rlx Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 22, 2021 Share Posted March 22, 2021 (edited) My question is that maybe its where Lee is writing all the files this may be in a restricted directory. For flip flop, a simple test a script file try to open 2 dwgs. Just put full path and dwg name eg c:\\mydwgs\\myprojects\\dwg1 Open dwg1 Open dwg2 If successful Lee may be watching, maybe use the vl-filename-mktemp rather than \USER......... need Flip Flop to confirm. Note Appdata is hidden suggesting higher admin level of control. Edited March 22, 2021 by BIGAL Quote Link to comment Share on other sites More sharing options...
rlx Posted March 22, 2021 Share Posted March 22, 2021 that's a good suggestion Bigal , but if OP's company policy is anything like mine it's not only about location but also extension. My company uses 'block everything except...' where every $%^& single file has to be 'white listed' and even updates of a program can mess things up and complete app has to be white listed all over again. But hey , it might work... I'm in a constant state of cold war with my IT department , I think of something and when they find out they find a way to block it... if they really hate me all they have to do is switch to AutoCad LT (don't tell them that I said that!) 1 1 Quote Link to comment Share on other sites More sharing options...
Flip Flop Posted March 22, 2021 Share Posted March 22, 2021 Same as rlx. Corporate policy - no SCR files. Anywhere. I can whitelist files but that's it. Quote Link to comment Share on other sites More sharing options...
Flip Flop Posted March 22, 2021 Share Posted March 22, 2021 19 hours ago, Lee Mac said: Unfortunately the AutoCAD SCRIPT command will only accept .scr files, and I'm not aware of a way to circumvent this restriction. The program could be written to update attribute values using ObjectDBX (similar to my old Global Attribute Editor), but this introduces a host of other issues such as misalignment for non-left justified attributes, restrictions on save format, and missing drawing thumbnails - consequently, I opted to abandon the use of ObjectDBX when developing this application. Thanks for the explanation. I suspected it wasn't going to be straight forward! Quote Link to comment Share on other sites More sharing options...
rlx Posted March 22, 2021 Share Posted March 22, 2021 I'm not sure if Lee's Batte has a 'script' mode (no dialog) else you could try the epic's approach (erase purge insert change and saveas). Works for simple drawings like instrument loops and wire diagrams where no paper space is used. Else you would need to use steal of similar to import layouts as well. Easy to add progress etc if you know a little about lisp. (defun c:FlipFlop ( / doc sp) (init) (runit) (princ)) (defun init () (vl-load-com) (defun *error* (m)(princ (strcat "\nComputer says no : " m)) princ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) sp (vla-get-modelspace doc)) ; (if (not (load "Lee's stuff" nil))(alert "Lee's stuff not loaded")) ) (defun runit ( / f l) (if (and (setq f (GetFolder "Where are your drawings?")) (vl-consp (setq l (alf f "*.dwg"))))(foreach d l (erase_all)(insert_dwg d)(do_your_stuff_here)(vla-saveas doc d)))) (defun insert_dwg (d / b) (if (vl-catch-all-error-p (setq b (vl-catch-all-apply 'vla-InsertBlock (list sp (vlax-3d-point 0 0 0) d 1.0 1.0 1.0 0.0)))) (princ (strcat "\n* error : " d " - " (vl-catch-all-error-message b))))(progn (vla-explode b)(vla-delete b))) (defun alf (f p) (if (and (= 'STR (type f)) (vl-file-directory-p (setq f (strcat (vl-string-right-trim "\\ "(vl-string-translate "/" "\\" f)) "\\")))) (apply 'append (cons (if (vl-directory-files f p) (mapcar '(lambda (x) (strcat f x)) (vl-directory-files f p))) (mapcar '(lambda (x) (alf (strcat f x) p)) (vl-remove ".." (vl-remove "." (vl-directory-files f nil -1)))))))) (defun GetFolder ( m / f s) (if (and (setq s (vlax-create-object "Shell.Application")) (setq f (vlax-invoke s 'browseforfolder 0 m 0 "")))(setq f (vlax-get-property (vlax-get-property f 'self) 'path)) (setq f nil))(vl-catch-all-apply 'vlax-release-object (list s)) (if f (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" f)) "\\"))) (defun erase_all () (vlax-for o sp (vl-catch-all-apply 'vla-delete (list o))) (vla-purgeall doc)) (defun create_txt (p s h) (entmake (list '(0 . "TEXT")(cons 10 p)(cons 1 s)(cons 50 0.0)(cons 40 h)(cons 72 1)(cons 73 2)(cons 11 p)))) ;;; call Lee's stuff here steal , batte ... whatever (defun do_your_stuff_here () ;;; just for example (create_txt (getvar 'viewctr) "FlipFlop was here" (/ (getvar 'viewsize) 20)) ) guess you could call it a script without using a script file 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 22, 2021 Share Posted March 22, 2021 If you look at what I posted you can get at the location and the file name. So add c:\users\......\LMAC_BAtte_V1-4.scr to whitelist. Give that a try. 1 Quote Link to comment Share on other sites More sharing options...
Flip Flop Posted March 24, 2021 Share Posted March 24, 2021 Thanks for the input. Meant to say that the SCR file (if our IT dept DO whitelist it) is effectively read-only and cannot be further edited by the user. Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 24, 2021 Share Posted March 24, 2021 We are a bit more free with our systems, can you save it to a pen drive and rename it on there as a scr file. Thinking about it, might need a computer offline to do that to the file Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 24, 2021 Share Posted March 24, 2021 Have you had IT read these posts so they understand what it is your trying to do. You can maybe have a directory just for CAD stuff that does allow scripts. I found this When developing software on a PC, Defender will usually flag your newly compiled executables because those are not recognized when compared against the database, the best option is to use one folder on your PC for all your coding projects, then add that folder to the exclusion list in Windows Defender, so nothing in that folder is scanned Quote Link to comment Share on other sites More sharing options...
Flip Flop Posted March 26, 2021 Share Posted March 26, 2021 On 24/03/2021 at 23:14, BIGAL said: Have you had IT read these posts so they understand what it is your trying to do. You can maybe have a directory just for CAD stuff that does allow scripts. I found this When developing software on a PC, Defender will usually flag your newly compiled executables because those are not recognized when compared against the database, the best option is to use one folder on your PC for all your coding projects, then add that folder to the exclusion list in Windows Defender, so nothing in that folder is scanned Yes, that's something I'm hoping they will allow. They won't. But I'm going to try anyway. Quote Link to comment Share on other sites More sharing options...
rlx Posted March 26, 2021 Share Posted March 26, 2021 Not sure why you would need to further edit the script file once created with batch edit. But if your IT guy doesn't allow this just tell him i think he is a big <bleep> and a <bleep> With lisp you can create temp files with vl-filename-mktemp , Autocad also has a folder to autosave files , stored in system var SAVEFILEPATH. You couls also try MYDOCUMENTSPREFIX. These are locations that should be writeable but they all mean diddly if the extension scr is blocked. So you would either need a folder with write permisson from IT , or maybe a fixed folder+filename.scr One draco way would be to use a file with txt extension but interp it as script. Haven't done much testing for this so not sure if this works for complex scripts or for scripts with more than one command per line but just maybe for simple scripts (saved with txt extension) this might just work : (defun c:txt2scr ( / n f s l)(vl-load-com)(if (and (setq n (getfiled "select txt file" "" "txt" 0)) (setq f (open n "r")))(progn (while (setq s (read-line f))(setq l (cons s l)))(close f)(if (vl-consp (setq l (mapcar '(lambda (s)(if (wcmatch s "(*)")(eval (read s)) s))(reverse l))))(foreach c l (command c)))))(princ)) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 27, 2021 Share Posted March 27, 2021 rlx I think your heading in correct direction, a script can be a lisp file. To flipflop I think were going in circles because you really need to say very clearly what do you want to do. Not just run script. Run something on start up? No problem does not need a script. Run something on multiple dwgs ? Run something on current dwg ? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 27, 2021 Share Posted March 27, 2021 (edited) 9 hours ago, Flip Flop said: Yes, that's something I'm hoping they will allow. They won't. But I'm going to try anyway. Funny .. this is an extension from 20 years ago that was a screensaver with potential malware. I remember using this for a 'Matrix' green digits screen .. well about 20 years ago. Edited March 27, 2021 by ronjonp Quote Link to comment Share on other sites More sharing options...
Mihail Posted November 16, 2022 Share Posted November 16, 2022 Hi, After multiple failures I'm gonna ask for help. I use very often this Lee Mac Batte V1-4.lsp to update revision blocks from a text file and works brilliant. To streamline the process and avoid an additional batch command to add that block to each drawing I have tried to add inside the code a sequence for the block insert but this is much too intricate for my knowledge and I could not make it work. I have a command I am using to insert the block before running the batte to edit the attributes: (defun c:REV0 () ;Inserts 'REV0' block (eraseblk "xxx") (eraseblk "xxxd") (command "tilemode" "0") (command "-purge" "all" "" "n") (command "-insert" "xxx" "2'-4 1/2,0'-6 3/16" "" "" "" "0" "" "" "" "" "") (princ) ) Is there anyone which could help me with this. Basically what I want is to run batte command, load attributes from a csv file ( I generate that with a different software to the right format - block name,tag,value) , select files where I want this applied. When the file is opened just before editing the attributes to insert the required block ( which is always the same). Is this even possible? Regards, Mihail Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 16, 2022 Share Posted November 16, 2022 When you do the -insert should also do the add attributes no need to insert then add attributes. If you use (vla-insertblock sp (vlax-3D-point p) n 1.0 1.0 1.0 0.0) then you need to add attributes again though I would use VLA-put function to fill in attributes. Your example has 1 insert but you refer to a csv file does this mean multi blocks to be inserted in 1 dwg ? Post a csv and dwg sample. 1 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.