+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
  1. #1
    Senior Member
    Discipline
    Mechanical
    Using
    Plant 3D not applicable
    Join Date
    Feb 2018
    Posts
    123

    Wink smal code to find itself LOL

    Registered forum members do not see this ad.

    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

  2. #2
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    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

  3. #3
    Senior Member
    Discipline
    Mechanical
    Using
    Plant 3D not applicable
    Join Date
    Feb 2018
    Posts
    123

    Default

    @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

  4. #4
    Senior Member
    Discipline
    Mechanical
    Using
    Plant 3D not applicable
    Join Date
    Feb 2018
    Posts
    123

    Default

    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

  5. #5
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    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


    Code:
    ; 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 "\\CLSID")))
    (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))

  6. #6
    Senior Member
    Discipline
    Mechanical
    Using
    Plant 3D not applicable
    Join Date
    Feb 2018
    Posts
    123

    Default

    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

  7. #7
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    sounds like a plan

  8. #8
    Senior Member
    Discipline
    Mechanical
    Using
    Plant 3D not applicable
    Join Date
    Feb 2018
    Posts
    123

    Default

    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

  9. #9
    Senior Member
    Discipline
    Mechanical
    Using
    Plant 3D not applicable
    Join Date
    Feb 2018
    Posts
    123

    Default

    someone made C++ code for it
    need visual studio to compile


    http://tbn2.blogspot.com.br/2014/06/...o-autocad.html

  10. #10
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by DGRL View Post
    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

Similar Threads

  1. code to find current cad version
    By wimal in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 16th Oct 2014, 02:31 am
  2. Replies: 6
    Last Post: 13th Jul 2011, 02:19 pm
  3. Find, Can't Find Square Bracket "["
    By jamesfear in forum AutoCAD General
    Replies: 8
    Last Post: 4th Aug 2010, 12:45 am
  4. [code] text [/code]
    By lpseifert in forum Feedback
    Replies: 4
    Last Post: 19th Jul 2010, 11:12 am
  5. Can't find DCL control code for text size...
    By LSR in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 14th Nov 2006, 10:09 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts