Jump to content

Open a folder from the command string AutoCAD


Nikon

Recommended Posts

18 hours ago, pkenewell said:
(startapp "explorer" "/e,\"C:\\Users\\Username\\Drawings24\\Office3.dwg\"")

 

15 hours ago, pkenewell said:
;;Test
(opendwg "C:\\Users\\Username\\Drawings24\\Office3.dwg")

 

Unfortunately, these 2 codes don't work...

 

8 hours ago, BIGAL said:
^c^COpen "C:\\Users\\Username\\Drawings24\\Office3.dwg"

AutoCAD freezes on this macro...

Link to comment
Share on other sites

5 hours ago, Nikon said:

Unfortunately, these 2 codes don't work...

Did you load the function (opendwg) before running the test? By that I mean did you copy the function below to the command line, or copy it into a .lsp file and load it with APPLOAD? I tested the function and it worked without issue. Try it again.

EDIT: In my original post - I neglected to comment out the argument description with a semi-colon, which probably caused it to fail to load. Please try it again now that it is properly commented. My apologies!

;; OPENDWG
;; Argument: dwg = string; the full path and file name of the drawing,
;; or just the file name if in the search path.
(defun opendwg (dwg)
   (vl-load-com)
   (vla-open (vla-get-activedocument (vlax-get-acad-object)) dwg)
)

 

Edited by pkenewell
Link to comment
Share on other sites

2 hours ago, pkenewell said:
;; OPENDWG
;; Argument: dwg = string; the full path and file name of the drawing,
;; or just the file name if in the search path.

Thanks, but the code gives an error
error: too few arguments.

this code ⬇️ works, it's enough for me:

(defun c:opendwg( / ) ;; open dwg
(startapp "explorer" "/e,\"C:\\Users\\Username\\Drawings24\\Office3.dwg\"")  
(princ)
)

or I can use a macro:  ⬇️

^C^C(startapp "explorer.exe" (findfile "c:/Users/username/Desktop/Drawings24/Office3.dwg"))

 

Edited by Nikon
Link to comment
Share on other sites

1 hour ago, Nikon said:

Thanks, but the code gives an error
error: too few arguments.

this code ⬇️ works, it's enough for me:

That's fine, but I am just trying to educate you. The (opendwg) is a function, not a command. You have to use it inside a command (defun C:...), or directly in a macro like this:

;; OPENDWG
;; Argument: dwg = string; the full path and file name of the drawing,
;; or just the file name if in the search path.
(defun opendwg (dwg)
   (vl-load-com)
   (vla-open (vla-get-activedocument (vlax-get-acad-object)) dwg)
)

(defun c:Openit ()
   (opendwg "C:\\Users\\Username\\Drawings24\\Office3.dwg")
)

AND this in a macro:

^C^COpenit

OR this directly:

^C^C(opendwg "C:\\Users\\Username\\Drawings24\\Office3.dwg")

 

Edited by pkenewell
  • Thanks 1
Link to comment
Share on other sites

An image pop menu example using same method as Pkenewell has suggested. Used for years.

 

**PIPES
[PIPES]
[COGGSLD(SD201,SUBSOIL)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG201") 
[COGGSLD(SD202,FLUSHOUT)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG202") 
[COGGSLD(SD203,CATCH)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG203") 
[COGGSLD(SD204,HOUSE)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG204") 
[COGGSLD(SD205,STREET)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG205") 
[COGGSLD(SD206,EASEMENT)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG206") 
[COGGSLD(SD207,ANCHOR)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG207") 

 

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

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...