DGRL Posted April 10, 2018 Share Posted April 10, 2018 Dear coders I was playing a little with the find file function and pure for learning I was wondering if it is possible to make a lisp that will find himself ATM I don't know what code to use to get the filename and the path of the LSP file I am not looking for another file then where the code is written in Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 You can check if a command is loaded with '(if c:my-func ... or with atoms-family , but you would still have to know in advance the filename containing your function definition. Or you would have to instruct your lisp file to set a global variable / list / array with it's path in it. Of course if you have many files that use a function called test that would be a little problematic. Also possible would be consistency between name of function and name of lisp file , function c:mylisp1 -> mylisp1.lsp. Whatever way , it can be done but think it has to be by design. Else you have scan for all lisp files , open them and see if a certain function lives inside... so if you want it , you have to plan it. gr. Rlx Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 @rlx Well that is hard coz I do not know where the file will be saved but I do need to do stuff with it like setting attributes (read-only o.i.d.) or simply delete the file or move it from where it is now to an specific folder Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 And the (dos_lisplist [T]) is not reliable because it gives back more then my custom loaded lsp files but less then what you can see with appload LOL Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 that's why all my (active) lisp files live together as one big little house on the prairie family in the same folder and this folder is at the top of my supportpath so findfile will always find it. Think Lee has a find-file routine , I have one too in my batch generator, don't know if I have all the subfunctions else search for RlxBatch ; find drawing objects - Thanks to TonyT, (probably) no way I would have been able to think this up, credit where credit's due ; just compressed and tweaked it a little bit (defun load_fso_scripting ( / server fso:progid fso:prefix ) (setq fso:progid "Scripting.FileSystemObject" fso:prefix "wsh-") (if (not wsh-get-drives) (if (not (setq server (CoGetClassServer fso:progid))) (alert "Error: Windows Scripting Host is not installed") (vlax-import-type-library :tlb-filename Server :methods-prefix fso:prefix :properties-prefix fso:prefix :constants-prefix (strcat ":" fso:prefix))))) (defun ProgID->CLSID (ProgID)(vl-registry-read (strcat "HKEY_CLASSES_ROOT\\" progid "[url="file://\\CLSID"]\\CLSID[/url]"))) (defun CoGetClassServer (progid) (CoGetClassProperty progid "InprocServer32")) (defun CoGetClassProperty (ProgID property / clsid) (if (setq clsid (ProgID->CLSID ProgID)) (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\CLSID\\" clsid "\\" property)))) ; FInd Drawing Objects - test : (setq lst (fido (dos_path "d:/temp/lisp"))) ; network test : (setq lst (fido (dos_path "//sabiccorp.sabic.com/eur/boz/Technical_Department/Acad.net/templates"))) (defun fido ( $f / fso fld rslt) (load_fso_scripting) (setq fso (vla-getInterfaceObject (vlax-get-acad-object) "Scripting.FileSystemObject") fld (wsh-GetFolder fso $f) rslt (fifo fld "*.dwg")) (vlax-release-object fld) (vlax-release-object fso) rslt) ; (setq lst (find-files (dos_path "d:/temp") "*.tif")) (defun find-files ( $f $e / fso fld rslt) (load_fso_scripting) (setq fso (vla-getInterfaceObject (vlax-get-acad-object) "Scripting.FileSystemObject") fld (wsh-GetFolder fso $f) rslt (fifo fld $e)) (vlax-release-object fld) (vlax-release-object fso) rslt) ; find in folders fl=file ,fls=files, sf=subfolder, sfl=subfolderlist, res=result (defun fifo ( %dir %ext / fl fls sf sfl res) (vlax-for fl (setq fls (wsh-get-files %dir)) (if (wcmatch (strcase (wsh-get-name fl) t) %ext)(setq res (cons (wsh-get-path fl) res)))(vlax-release-object fl)) (vlax-release-object fls) (vlax-for sf (setq sfl (wsh-get-SubFolders %dir)) (setq res (append res (fifo sf %ext)))(vlax-release-object sf)) (please_release_me_let_me_go (list sfl)) res) (defun dos_path ( $p ) (if (= (type $p) 'str) (strcase (vl-string-translate "/" "\\" $p)) "")) (defun please_release_me_let_me_go (lst) (mapcar '(lambda(x) (if (and (= 'vla-object (type x)) (not (vlax-object-released-p x))) (vlax-release-object x))(set (quote x) nil)) lst)) Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 I have to approach this different @RLX I think I have to make adjustments and hardcode the filename inside the LSP and use FINDFILE to get the path Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 sounds like a plan Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 LOL Going to block all other LSP files in use here if they do not have the "Check" build in A lot of designers are not going to like this ( have no other choice atm until I find a good solution ) No I am the IT guy who screws with the coders Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 someone made C++ code for it need visual studio to compile http://tbn2.blogspot.com.br/2014/06/lista-das-lisps-carregadas-no-autocad.html Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 LOL Going to block all other LSP files in use here if they do not have the "Check" build in A lot of designers are not going to like this ( have no other choice atm until I find a good solution ) No I am the IT guy who screws with the coders glad you're not my boss hahahaha Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 I would give you a greencard LOL Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 I would give you a greencard LOL have created my own green card (not fully functional , but almost) ps. in the options dialog 'S activates support dialog :-) RlxProfile.lsp Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 send me pm with explanation about this lsp Is this making an "profile" is AutoCAD with all needed settings? Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 Oh btw , IT apologized for the script thingy... I may use them for AutoCAD , but the extension scr is forbidden when it comes to email (as attachments) ... well , I can either paste the commands in mail body or rename scr file to txt should I have the need to mail them so that's one problem less , at least until the next time... gr. Rlx Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 parrantly is was never their intention to block it for use in ACAD well I can also live with the block in email that's what we call safety m8 I can easily break in using SCR in email using auto activation LOL Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 RLX Do you have Visual studio? someone made C++ code for it need visual studio to compile http://tbn2.blogspot.com.br/2014/06/...o-autocad.html Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2018 Share Posted April 10, 2018 RLX Do you have Visual studio? someone made C++ code for it need visual studio to compile http://tbn2.blogspot.com.br/2014/06/...o-autocad.html nope , but I believe you can download it for free from micro softies ,special home edition https://www.visualstudio.com/free-developer-offers/ Quote Link to comment Share on other sites More sharing options...
DGRL Posted April 10, 2018 Author Share Posted April 10, 2018 MICRO SOFTIES :rofl::rofl: 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.