Jump to content

Recommended Posts

Posted

I did a search for a similar thread but with no luck.

 

Anyway... I was hoping to find a thread that talked about whether or not it is possible to create a lisp that will open up a specific folder. Kind of like a command that has within it a search path.

 

Now when I want to go to this folder I have to browse through several others before I get to the one I want. I would like to be able to type in a command and it would magically open up to the folder I need... Unfortunately I have no idea how in depth of a routine this has to be or how to even begin writing it.

 

Something that may help, is that it is always the same folder that I need... So since it is always the same folder I am hoping it doesn't have to be as complex.

 

Thank you in advance for any advice/help any of you have :)

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    6

  • Se7en

    5

  • MFish

    5

  • CADkitt

    2

Top Posters In This Topic

Posted

How about?

(if 
   (= (getvar 'dwgtitled) 1) 
   (startapp "explorer" (getvar 'dwgprefix)) 
   )

Posted
How about?

(if 
   (= (getvar 'dwgtitled) 1) 
   (startapp "explorer" (getvar 'dwgprefix)) 
   )

 

That makes good sense... I am having trouble remembering exactly what I need to get the routine going though. Like the command I would use to get it started once it is loaded. :unsure:

 

Sorry about my lack of knowledge I am still in the basic stages of using Lisp routines and such. :(

Posted

Here it is. Ive taken the liberty to name the command `OPENEX' but you can name it anything you want by changing it (leave the "c:" and the "( / )" parts).

 

(defun c:OpenEX ( / )
 (if 
   (= (getvar 'dwgtitled) 1) 
   (startapp "explorer" (getvar 'dwgprefix)) 
   )
 )

Posted
Here it is. Ive taken the liberty to name the command `OPENEX' but you can name it anything you want by changing it (leave the "c:" and the "( / )" parts).

 

(defun c:OpenEX ( / )
 (if 
   (= (getvar 'dwgtitled) 1) 
   (startapp "explorer" (getvar 'dwgprefix)) 
   )
 )

 

 

Oh okay! I will give that a shot, thank you very much!

Posted

Once you get it going, dont forget to drop it in your appload startupsuite so you can access it from any drawing. Also I would shorten the OpenEx to OEX just to make it quicker to type at the command line...

 

nice S8.

Posted

> Oh okay! I will give that a shot, thank you very much!

Your welcome very much.

Posted
Once you get it going, dont forget to drop it in your appload startupsuite so you can access it from any drawing. Also I would shorten the OpenEx to OEX just to make it quicker to type at the command line...

 

nice S8.

 

That is a nice suggestion, thank you!

 

> Oh okay! I will give that a shot, thank you very much!

Your welcome very much.

 

 

Okay, I tried using it and the first time I received back a nil response... Then I tried inserting the file path into the routine and it came back with error bad argument.

 

Here is the file path that I inserted, I am sure you will know what I did wrong...

 

(defun c:OEX ( / )

(if

(= (getvar 'G:\Automation\Drawing Patterns\AutoCAD STD\Library\Panel\Square D\PLC) 1)

(startapp "explorer" (getvar 'G:\Automation\Drawing Patterns\AutoCAD STD\Library\Panel\Square D\PLC))

)

)

Posted

The code will only follow through when the drawing has been saved - i.e. when dwgtitled = 1.

 

If it is the same thing you need everytime - maybe this:

 

(defun c:OEX ( / )
(startapp "explorer" "G:\\Automation\\Drawing Patterns\\AutoCAD STD\\Library\\Panel\\Square D\\PLC")
) 

Posted

Otherwise perhaps this?

 

(defun c:getfile  (/ file)
 (setq file
        (if load_file
          (getfiled "Select File" load_file "" 2)
          (getfiled "Select File" "" "" 2)))
 (or (not file) (setq load_file file)))

Posted

1. Paths have to have either double slashes like: "C:\\Temp\\My Dir\\" or a forward slash like: "C:/Temp/My Dir/"

 

Yes that will only work if the drawing has been saved. And you should have a problem with it. I dont know why it would give you an error.

 

2. Lee Mac's last code: I can see that stupid `IF this then that then OR' has infected this forum as well. ...I'll have to correct that. :P

Posted
1. Paths have to have either double slashes like: "C:\\Temp\\My Dir\\" or a forward slash like: "C:/Temp/My Dir/"

 

Yes that will only work if the drawing has been saved. And you should have a problem with it. I dont know why it would give you an error.

 

Can't believe I missed the single backslash - nice spot Se7en... :oops:

 

2. Lee Mac's last code: I can see that stupid `IF this then that then OR' has infected this forum as well. ...I'll have to correct that. :P

 

Haha - whats wrong with a use of a good ol' OR...

 

either that or its (if (not this), then this...)

Posted

> Haha - whats wrong with a use of a good ol' OR...

Nothing when preforming a boolean check.

 

(defun c:getfile  (/ file)
 (setq file
  ;; bind variable FILE to results from GETFILED
        (if load_file
          ;; where did this var come from? 
          ;; Are you using a global var called load_file?
          (getfiled "Select File" load_file "" 2)
          (getfiled "Select File" "" "" 2))
        ;; the IF statement will return the results from GETFILED
        )
 (or ; Run boolean; stop on first non nil statement
   (not file) 
   ;; 1. if the variable FILE is bound to nil then
   ;; 2. if the variable is bound then
   (setq load_file file)
   ;; 1. bind the variable LOAD_FILE to nil
   ;; 2. never evaluate this statement
  )
)

 

Sorry, I dont really follow your logic in this one.

Posted

Hmmm... I followed it like this:

 

(defun c:getfile  (/ file)
 (setq file
  ;; bind variable FILE to results from GETFILED
        (if load_file
          ;; where did this var come from? [b][color=Blue]<<-- Using it as a global Variable[/color][/b] 
          ;; Are you using a global var called load_file?  [b][color=Blue]<<-- Yes[/color][/b]
          (getfiled "Select File" load_file "" 2)
          (getfiled "Select File" "" "" 2))
        ;; the IF statement will return the results from GETFILED
        )
 (or ; Run boolean; stop on first non nil statement
   (not file) 
[color=Red][b]    ;; 1. if the variable FILE is bound to nil then (not file) returns T
   ;; 2. if the variable is bound then  (not file) returns nil[/b][/color]
   (setq load_file file)
[color=Red][b]    ;; 1. don't evaluate this statement
   ;; 2. bind its value to the global variable[/b][/color]
  )
)

Posted
1. Paths have to have either double slashes like: "C:\\Temp\\My Dir\\" or a forward slash like: "C:/Temp/My Dir/"

 

Yes that will only work if the drawing has been saved. And you should have a problem with it. I dont know why it would give you an error.

 

2. Lee Mac's last code: I can see that stupid `IF this then that then OR' has infected this forum as well. ...I'll have to correct that. :P

 

 

That's good to know, I wasn't aware of the backslash issue.

 

And just an update, both of the routines work flawlessly! And I must tip my hat to you both! That's a great help, and thank you for being so quick about everything :)

Posted

Not sure what you require but if this helps well and good.

 

 

 

(defun c:JOB () 
(setq jobnumber (getstring "\nTYPE JOB NUMBER"))
(setq first2chars (substr jobnumber 1 2))
(setq jobfolder (strcat "[url="file://\\Jobs"]\\Jobs[/url] 20" first2chars))
 (setq path1 (strcat "R:"))
 (setq path2 (strcat "\\"))
 (setq FullPath (Strcat path1 jobfolder path2 jobnumber))
 (startapp "Explorer" FullPath)
 (princ)
)

Posted
Not sure what you require but if this helps well and good.

 

 

 

(defun c:JOB () 
(setq jobnumber (getstring "\nTYPE JOB NUMBER"))
(setq first2chars (substr jobnumber 1 2))
(setq jobfolder (strcat "[url="file://%5C%5CJobs"]\\Jobs[/url] 20" first2chars))
 (setq path1 (strcat "R:"))
 (setq path2 (strcat "\\"))
 (setq FullPath (Strcat path1 jobfolder path2 jobnumber))
 (startapp "Explorer" FullPath)
 (princ)
)

 

 

Russell, I think that code is quite specific for your purpose - but thanks for the post all the same :)

  • 1 year later...
Posted

I'm trying to make a command for in toolpallets so you can open the folder of the current tool pallet.

but this doesn't work:

  • ^c^c(startapp "explorer" "I:\\Engineering\\Equipment\\name\\01010")
  • ^c^c(startapp "explorer" "I:\Engineering\Equipment\name\01010")
  • ^c^c(startapp "explorer" "I://Engineering//Equipment//name//01010")
  • ^c^c(startapp "explorer" "I:/Engineering/Equipment/name/01010")

I rather not use a lisp because the tool pallets get distributed true the network.

Found this similar thread: http://www.eng-tips.com/viewthread.cfm?qid=13388&page=207

Doesn't really have an solution except using your internet browser.

Posted

For a macro, what about this:

 

 
_.browser;"I:/Engineering/Equipment/name/01010"

 

I would like to hear if it works!

Posted
For a macro, what about this:

 

 
_.browser;"I:/Engineering/Equipment/name/01010"

 

I would like to hear if it works!

Browser works fine only if you use internet explorer if you have chrome you get the dir in chrome and I guess the same results in fire-fox. I now use this and have the chrome ie tab extension set up to automatically load file://. It works but not without extra work. Maybe there is a way to force IE on open?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...