Author Topic: I think my brain went on vacation  (Read 8057 times)

0 Members and 1 Guest are viewing this topic.

PDJ

  • Guest
I think my brain went on vacation
« on: February 14, 2005, 03:55:50 PM »
What I'm trying to do is this:

We have 60 villages that we provide telephone support to in the bush here in Alaska.  Each village has it's own directory and under each directory is a map with the villages exchange number as a name (i.e. 231oa.dwg).

What I'm trying to do is write a simple lisp that when loaded will have all my village directories and map names in there so that when I'm in AutoCad, I can just type x231 on the command line and it will open that villages map.  

I know that filedia has to be switched to 0 at the start and returned to 1 at the end.  

Here's what I have that isn't working so far.. :D

Code: [Select]
(defun C:X231()
  (command "filedia" "0")
  (command "OPEN" "T:\\PRM\\Birch Creek\\231OA.DWG" )
  (command "filedia" "1")
  )


I'm getting the following as an error:
Unknown command "T:\PRM\BIRCH CREEK\231OA.DWG"

I've tried with without the quotes but then it just gives me a nil..

I'm pretty sure this is a simple fix but, I can think very hard today..  Any help is greatly appreciated.  My brain is fried from a lovely flu virus I've had for the last 4 days..

Thanks!

PDJ

  • Guest
I think my brain went on vacation
« Reply #1 on: February 14, 2005, 07:13:06 PM »
Is this a toughie?? 24 views so far and no comments or anything??  Hmmm..

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #2 on: February 14, 2005, 07:47:08 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #3 on: February 14, 2005, 07:48:34 PM »
Here is another one to try.
Code: [Select]
(command "vbastmt" (strcat
   "AcadApplication.Documents.Open " (chr 34) filnam (chr 34)))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
I think my brain went on vacation
« Reply #4 on: February 14, 2005, 08:01:55 PM »
I use a variation of this :
Code: [Select]

(defun c:xtest ()  
  (if (setq tmp (findfile "F:\\Develop\\test\\Standards-012.DWG"))
    (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) tmp))
    (alert "Can't find file : \n F:\\Develop\\test\\Standards-012.DWG")
  )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

PDJ

  • Guest
I think my brain went on vacation
« Reply #5 on: February 14, 2005, 08:40:57 PM »
Dag nabbit CAB, I tole yas my brain was fried.. hehe..   I think Kerry's is close enough.. Now I just gotta copy it 60 times in my lisp file and change all the name..

Thanks for the help you two!!

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
I think my brain went on vacation
« Reply #6 on: February 14, 2005, 08:46:19 PM »
Quote from: PDJ
<snip> .. Now I just gotta copy it 60 times in my lisp file and change all the name.. </snip>


Your kidding right?!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
I think my brain went on vacation
« Reply #7 on: February 14, 2005, 09:38:36 PM »
Set the value of SDI to 1 and you "should" be able to use the (command "open" ...) without incident.

When the SDI interface was implemented, "open" was modified and the problems started.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

PDJ

  • Guest
I think my brain went on vacation
« Reply #8 on: February 15, 2005, 01:19:45 PM »
se7en, that's how many different paths I have to be able to access.  This is the main reason I wanted a routine like this.  If I'm missing something, please let me know..

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
I think my brain went on vacation
« Reply #9 on: February 15, 2005, 01:50:31 PM »
PDJ,

Your a beginner at lisp right?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

<spell check police>

  • Guest
I think my brain went on vacation
« Reply #10 on: February 15, 2005, 02:02:30 PM »
"You are a" or "You're a", but not "your a".

<spank.mpg>

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
I think my brain went on vacation
« Reply #11 on: February 15, 2005, 02:08:20 PM »
hummm?! Hey while i have your attention officer; Could you tell me if i spelled this right?

BAN!!!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
I think my brain went on vacation
« Reply #12 on: February 15, 2005, 02:25:03 PM »
Quote from: PDJ
se7en, that's how many different paths I have to be able to access.  This is the main reason I wanted a routine like this.  If I'm missing something, please let me know..

PDJ, rather than rewriting a routine for each path, create a routine that will define the lisps for you. By creating a master list that you can add to, delete from, modify at will it will make your job now, and in the future, much easier.

For instance:
Code: [Select]

(defun c:make_the_lisps (/ master_list)
  (setq master_list '(("231" . "Path-to-231.dwg")
     ("491" . "Path-to-491.dwg")
     ;add all your villages like so
     )
)
  (foreach village master_list
    (eval (read (strcat "(defun " "c:x" (car village)
" () (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object))\""
(cdr village) "\")))")
 )
 )
    )
  )
 

This will create a new lisp function that can be called from the command line, as you said you wanted, for each village listed in the master_list. Then you just need to call this one lisp in your acaddoc.lsp file

Is that what you had in mind Se7en?

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
I think my brain went on vacation
« Reply #13 on: February 15, 2005, 02:35:25 PM »
*blink*

*sigh*

No.

I was gonna show him 'arguments'.

show-off!

:P :D
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #14 on: February 15, 2005, 03:45:18 PM »
How about this, Paul?
You enter XLD 232 [enter] at the command line.
The space between D & 2 starts the routine.
You will have to maintain the list within the lisp.
You could use a text file read routine to read the list from a text file.


Code: [Select]
;;  X Load
(defun c:xld (/ ac_list ac filen tmp)
  (setq ac_list
         (list
           (list "231" "T:\\PRM\\Birch Creek\\231OA.DWG")
           (list "232" "T:\\PRM\\Birch Creek\\232OA.DWG")
           (list "233" "T:\\PRM\\Birch Creek\\233OA.DWG")
         )
  )
  (if (setq ac (getstring "\nEnter the area code for the project to load. "))
    (if (setq filen (assoc ac ac_list))
      (progn
        (setq filen (cdr filen))
         ;;  from Kerry Brown
        (if (setq tmp (findfile filen))
          (vla-activate
            (vla-open (vla-get-documents (vlax-get-acad-object)) tmp)
          )
          (alert (strcat "Can't find file : " filen))
        )
      )
      (alert (strcat filen " is not in the list."))
    )
  )
  (princ)
)
(prompt "\n***  XLD loaded, enter XLD followed by the area code to run [XLD 321].")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
I think my brain went on vacation
« Reply #15 on: February 15, 2005, 03:54:21 PM »
Quote from: <spell check police>
"You are a" or "You're a", but not "your a".

<spank.mpg>

ROTFLMAO .................  :lol:

man that was good........ I haven't laughed like that in months.
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #16 on: February 15, 2005, 04:03:40 PM »
Quote from: Mark Thomas
Quote from: <spell check police>
"You are a" or "You're a", but not "your a".

<spank.mpg>

ROTFLMAO .................  :lol:

man that was good........ I haven't laughed like that in months.

I thought it was funny too but didn't laugh too hard
because they will be after me next. :horror:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dubb

  • Swamp Rat
  • Posts: 1105
I think my brain went on vacation
« Reply #17 on: February 15, 2005, 04:24:14 PM »
Quote from: Se7en
hummm?! Hey while i have your attention officer; Could you tell me if i spelled this right?

BAN!!!


omg..is there really a spell check police?

PDJ

  • Guest
I think my brain went on vacation
« Reply #18 on: February 15, 2005, 06:34:04 PM »
Alright CAB, I tried your way, coulda sworn I checked it with just a few and now that I have all the villages loaded, it doesn't work.. Take a look if you will and see if you see any glaring errors.  Main thing I did is change the name from xld to xx and added all those dang villages.  FYI, the T: is a network drive but, I don't think that's a problem.

Code: [Select]
(defun c:xx (/ ac_list ac filen tmp)
  (setq ac_list
       (list
         (list "231" "T:\\PRM\\Birch Creek\\221OA.DWG")
         (list "237" "T:\\PRM\\newtokk\\237oa.DWG")
         (list "238" "T:\\PRM\\alakanuk\\238oa.DWG")
         (list "256" "T:\\PRM\\tuntutuliak\\256oa.DWG")
         (list "293" "T:\\PRM\\nikolai\\293oa.DWG")
         (list "295" "T:\\PRM\\livengood\\295oa.DWG")
         (list "298" "T:\\PRM\\takotna\\298oa.DWG")
         (list "358" "T:\\PRM\\rampart\\358oa.DWG")
         (list "427" "T:\\PRM\\toksook bay\\427oa.DWG")
         (list "438" "T:\\PRM\\st marys\\438oa.DWG")
         (list "467" "T:\\PRM\\chuathbaluk\\467oa.DWG")
         (list "477" "T:\\PRM\\kasigluk\\477oa.DWG")
         (list "478" "T:\\PRM\\stevens village\\478oa.DWG")
         (list "493" "T:\\PRM\\togiak\\493oa.DWG")
         (list "496" "T:\\PRM\\nunam iqua\\496oa.DWG")
         (list "520" "T:\\PRM\\central\\520oa.DWG")
         (list "524" "T:\\PRM\\mcgrath\\524oa.DWG")
         (list "525" "T:\\PRM\\twin hills\\525oa.DWG")
         (list "526" "T:\\PRM\\lime village\\526oa.DWG")
         (list "527" "T:\\PRM\\nunapitchuk\\527oa.DWG")
         (list "536" "T:\\PRM\\eek\\536oa.DWG")
         (list "543" "T:\\PRM\\bethel\\543oa.DWG")
         (list "549" "T:\\PRM\\pilot station\\549oa.DWG")
         (list "553" "T:\\PRM\\atmautluak\\553oa.DWG")
         (list "556" "T:\\PRM\\quinhagak\\556oa.DWG")
         (list "557" "T:\\PRM\\kongiganak\\557oa.DWG")
         (list "558" "T:\\PRM\\scammon bay\\558oa.DWG")
         (list "573" "T:\\PRM\\chenega bay\\573oa.DWG")
         (list "584" "T:\\PRM\\russian mission\\584oa.DWG")
         (list "587" "T:\\PRM\\arctic village\\587oa.DWG")
         (list "588" "T:\\PRM\\kwigillingok\\588oa.DWG")
         (list "589" "T:\\PRM\\napakiak\\589oa.DWG")
         (list "591" "T:\\PRM\\mt village\\591oa.DWG")
         (list "624" "T:\\PRM\\unalakleet\\624oa.DWG")
         (list "628" "T:\\PRM\\beaver\\628oa.DWG")
         (list "647" "T:\\PRM\\nightmute\\647oa.DWG")
         (list "652" "T:\\PRM\\tununak\\652oa.DWG")
         (list "672" "T:\\PRM\\manley hs\\672oa.DWG")
         (list "674" "T:\\PRM\\l minchumina\\674oa.DWG")
         (list "679" "T:\\PRM\\marshall\\679oa.DWG")
         (list "695" "T:\\PRM\\tuluksak\\695oa.DWG")
         (list "737" "T:\\PRM\\napaskiak\\737oa.DWG")
         (list "757" "T:\\PRM\\kwethluk\\757oa.DWG")
         (list "758" "T:\\PRM\\hooper bay\\758oa.DWG")
         (list "765" "T:\\PRM\\akiak\\765oa.DWG")
         (list "798" "T:\\PRM\\minto\\798oa.DWG")
         (list "825" "T:\\PRM\\akiachak\\825oa.DWG")
         (list "827" "T:\\PRM\\mekoryuk\\827oa.DWG")
         (list "848" "T:\\PRM\\chalkyitsik\\848oa.DWG")
         (list "849" "T:\\PRM\\venetie\\849oa.DWG")
         (list "858" "T:\\PRM\\chevak\\858oa.DWG")
         (list "867" "T:\\PRM\\chefornak\\867oa.DWG")
         (list "896" "T:\\PRM\\kipnuk\\896oa.DWG")
         (list "899" "T:\\PRM\\kotlik\\899oa.DWG")
         (list "949" "T:\\PRM\\emmonak\\949oa.DWG")
         (list "967" "T:\\PRM\\goodnews bay\\967oa.DWG")
         (list "979" "T:\\PRM\\platinum\\979oa.DWG")
         (list "984" "T:\\PRM\\savoonga\\984oa.DWG")
         (list "985" "T:\\PRM\\gambell\\985oa.DWG")
         )
  )
  (if (setq ac (getstring "\nEnter the area code for the project to load. "))
    (if (setq filen (assoc ac ac_list))
      (progn
        (setq filen (cdr filen))
         ;;  from Kerry Brown
        (if (setq tmp (findfile filen))
          (vla-activate
            (vla-open (vla-get-documents (vlax-get-acad-object)) tmp)
          )
          (alert (strcat "Can't find file : " filen))
        )
      )
      (alert (strcat filen " is not in the list."))
    )
  )
  (princ)
)
(prompt "\n***  XX loaded, enter XX followed by the area code to run [XX 321].")
(princ)


Thanks for the help guys and dolls!!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #19 on: February 15, 2005, 06:50:43 PM »
Sorry Paul
Change this:
Code: [Select]
(setq filen (cdr filen))
to this:
Code: [Select]
(setq filen (cadr filen))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

TR

  • Guest
I think my brain went on vacation
« Reply #20 on: February 15, 2005, 07:16:15 PM »
Quote from: CAB
http://groups-beta.google <snip>


Make a bookmark in your browser and put the following for the path:

Code: [Select]
javascript:void(location.href='http://tinyurl.com/create.php?url='+location.href)

 :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #21 on: February 15, 2005, 07:47:49 PM »
Thanks Tim
I updated the post. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

PDJ

  • Guest
I think my brain went on vacation
« Reply #22 on: February 15, 2005, 08:12:55 PM »
Works like a charm now CAB.. Many thanks!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I think my brain went on vacation
« Reply #23 on: February 15, 2005, 09:51:35 PM »
You're welcome.
Here is another version.
Code: [Select]
(defun c:xx (/ ac_list ac filen tmp)
  (setq ac_list
       (list
         (list "231" "Birch Creek")
         (list "237" "newtokk")
         (list "238" "alakanuk")
         (list "256" "tuntutuliak")
         (list "293" "nikolai")
         (list "295" "livengood")
         (list "298" "takotna")
         (list "358" "rampart")
         (list "427" "toksook bay")
         (list "438" "st marys")
         (list "467" "chuathbaluk")
         (list "477" "kasigluk")
         (list "478" "stevens village")
         (list "493" "togiak")
         (list "496" "nunam iqua")
         (list "520" "central")
         (list "524" "mcgrath")
         (list "525" "twin hills")
         (list "526" "lime village")
         (list "527" "nunapitchuk")
         (list "536" "eek")
         (list "543" "bethel")
         (list "549" "pilot station")
         (list "553" "atmautluak")
         (list "556" "quinhagak")
         (list "557" "kongiganak")
         (list "558" "scammon bay")
         (list "573" "chenega bay")
         (list "584" "russian mission")
         (list "587" "arctic village")
         (list "588" "kwigillingok")
         (list "589" "napakiak")
         (list "591" "mt village")
         (list "624" "unalakleet")
         (list "628" "beaver")
         (list "647" "nightmute")
         (list "652" "tununak")
         (list "672" "manley hs")
         (list "674" "l minchumina")
         (list "679" "marshall")
         (list "695" "tuluksak")
         (list "737" "napaskiak")
         (list "757" "kwethluk")
         (list "758" "hooper bay")
         (list "765" "akiak")
         (list "798" "minto")
         (list "825" "akiachak")
         (list "827" "mekoryuk")
         (list "848" "chalkyitsik")
         (list "849" "venetie")
         (list "858" "chevak")
         (list "867" "chefornak")
         (list "896" "kipnuk")
         (list "899" "kotlik")
         (list "949" "emmonak")
         (list "967" "goodnews bay")
         (list "979" "platinum")
         (list "984" "savoonga")
         (list "985" "gambell")
         )
        prefix "T:\\PRM\\"
        suffix "oa.DWG"
  )
  (if (setq ac (getstring "\nEnter the area code for the project to load. "))
    (if (setq filen (assoc ac ac_list))
      (progn
        (setq filen (strcat prefix (cadr filen) "\\" ac suffix ))
         ;;  from Kerry Brown
        (if (setq tmp (findfile filen))
          (vla-activate
            (vla-open (vla-get-documents (vlax-get-acad-object)) tmp)
          )
          (alert (strcat "Can't find file : " filen))
        )
      )
      (alert (strcat filen " is not in the list."))
    )
  )
  (princ)
)
(prompt "\n***  XX loaded, enter XX followed by the area code to run [XX 321].")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
I think my brain went on vacation
« Reply #24 on: February 15, 2005, 10:47:38 PM »
Here's my quick 2¢ food for thought effort (untested) --

Code: [Select]
(defun c:xx
   
    (   /  
        areaCodes
        areaCode
        cityName
        fileName
        filePrefix
        fileSuffix
        filePath
        openedOK
    )

    (setq areaCodes
       '(
            ("231" . "Birch Creek")
            ("237" . "newtokk")
            ("238" . "alakanuk")
            ("256" . "tuntutuliak")
            ("293" . "nikolai")
            ("295" . "livengood")
            ("298" . "takotna")
            ("358" . "rampart")
            ("427" . "toksook bay")
            ("438" . "st marys")
            ("467" . "chuathbaluk")
            ("477" . "kasigluk")
            ("478" . "stevens village")
            ("493" . "togiak")
            ("496" . "nunam iqua")
            ("520" . "central")
            ("524" . "mcgrath")
            ("525" . "twin hills")
            ("526" . "lime village")
            ("527" . "nunapitchuk")
            ("536" . "eek")
            ("543" . "bethel")
            ("549" . "pilot station")
            ("553" . "atmautluak")
            ("556" . "quinhagak")
            ("557" . "kongiganak")
            ("558" . "scammon bay")
            ("573" . "chenega bay")
            ("584" . "russian mission")
            ("587" . "arctic village")
            ("588" . "kwigillingok")
            ("589" . "napakiak")
            ("591" . "mt village")
            ("624" . "unalakleet")
            ("628" . "beaver")
            ("647" . "nightmute")
            ("652" . "tununak")
            ("672" . "manley hs")
            ("674" . "l minchumina")
            ("679" . "marshall")
            ("695" . "tuluksak")
            ("737" . "napaskiak")
            ("757" . "kwethluk")
            ("758" . "hooper bay")
            ("765" . "akiak")
            ("798" . "minto")
            ("825" . "akiachak")
            ("827" . "mekoryuk")
            ("848" . "chalkyitsik")
            ("849" . "venetie")
            ("858" . "chevak")
            ("867" . "chefornak")
            ("896" . "kipnuk")
            ("899" . "kotlik")
            ("949" . "emmonak")
            ("967" . "goodnews bay")
            ("979" . "platinum")
            ("984" . "savoonga")
            ("985" . "gambell")
        )
    )
   
    (setq
        filePrefix "T:\\PRM\\"
        fileSuffix "oa.DWG"
    )  
   
    (setq areaCode
        (getstring
            (strcat
                "\nEnter the area code "
                "for the project to load. "
            )    
        )
    )

    (cond
   
        (  
            (and
       
                (setq cityName
                    (cdr
                        (assoc
                            areaCode
                            areaCodes
                        )
                    )
                )
           
                (setq fileName
                    (strcat
                        filePrefix
                        cityName
                        "\\"
                        areaCode
                        fileSuffix
                    )
                )
               
                (setq filePath
                    (findfile fileName)
                )
               
                ;;  compliments Kerry Brown; slight massage

                (   (lambda (result)
                        (setq openedOK
                            (null
                                (vl-catch-all-error-p result)
                            )
                        )
                    )
                    (vl-catch-all-apply
                       '(lambda()                                
                            (vla-activate
                                (vla-open
                                    (vla-get-documents
                                        (vlax-get-acad-object)
                                    )
                                    filePath
                                )
                            )
                        )
                    )
                )    
            )
        )
       
        (   (null cityName)
            (alert
                (strcat
                    "<" areaCode ">"
                    " is not a valid area code."
                )
            )
        )
       
        (   (null filePath)
            (alert
                (strcat
                    "Can't find file: "
                    fileName
                )
            )
        )
        (   (null openedOK)
            (alert
                (strcat
                    "Problem opening "
                    filePath
                    "."
                )
            )
        )
        (   t
            (princ "We're not sure what happened.")
        )
    )
   
    (princ)
   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst