Author Topic: I think my brain went on vacation  (Read 8056 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.