Jump to content

Recommended Posts

Posted

Is there a way around having spaces in a network path location and/or spaces in a filename? For example:

 

(defun c:test (/ )
(command "start" "c:\\Data\\Current Excel Programs\\2017 file gen.xls")
(princ ))

 

hangs up on me. I have to put it like this (with underscores) to work:

 

(defun c:test (/ )
(command "start" "c:\\Data\\Current_Excel_Programs\\2017_file_gen.xls")
(princ ))

 

This is not necessarily a problem, I'm just wondering if there's a way around it.

Thank you.

Posted

Thank you tombu for the lead. And as always Thank you Lee Mac! You guys are SuperBomb!

Posted

Thanks for the recommendation tombu :thumbsup:

 

Another alternative could be:

(startapp "explorer" "\"c:\\Data\\Current Excel Programs\\2017 file gen.xls\"")

Posted

Had the same problem with block names, opening the external block dwg.

 

; (openblk "P:/ACADSTDS/CIVIL STANDARDS/AD00702") 
(defun openblk (blkname / adocs)
(setq acDocs (vla-get-documents (vlax-get-acad-object)))
(vla-open acDocs blkname)
(vla-activate (vla-item acdocs 1))
)

Posted

In code I generally use (chr 92) for "\\" and (chr 47) for "/" so it works the same in macros as it does on the command line.

 

One more with a few examples for opening various file types:

(defun MyOpen (FileName ReadOnly / )
;  (while (vl-string-search  "\\" FileName) (setq FileName (vl-string-subst "/" "\\" FileName)))
;  (while (vl-string-search  "/" FileName) (setq FileName (vl-string-subst "\\" "/" FileName)))
 (vla-activate
   (vla-Open
     (vla-get-Documents  (vlax-get-Acad-Object))
     FileName
     (if ReadOnly :vlax-true :vlax-false)
   )
 )
)
;|(MyOpen (strcat (getvar "roamablerootprefix")"Support" (chr 92) "acaddoc.lsp") nil)(princ))
(MyOpen "C:\\Documents and Settings\\User\\Application Data\\Autodesk\\AutoCAD Map 3D 2008\\R17.1\\enu\\support\\acaddoc.lsp" nil)
^C^C^P(or openfile(load "MyOpen.lsp"));(openfile "Description Key Code.doc")
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(openfile "G:/DavidK/Feature Code Listing.mht")
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "G:/TOMBU/Blocks/Leon_County_Plans_Binder.dwg" nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "MapAnnotation.txt" nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (getenv "QnewTemplate") nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (strcat (getvar "localrootprefix") "template" (chr 92) "map2d_Leon.dwt") nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (strcat (getvar "localrootprefix") "template" (chr 92) "FLHP-NF.dwt") nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "FLHP-NF.dwt" nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "" nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "" nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "acaddoc.lsp" nil)(princ)

^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (strcat (getvar "localrootprefix") "template" (chr 92) "FLHP-NF.dwt") nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (strcat (getvar "localrootprefix") "template" (chr 92) "map2d_Leon.dwt") nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (getenv "QnewTemplate") nil)(princ)
^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "//Pubworks/Sys2/USERS/ENGDESGN/BeaufordT/Blocks/Leon_County_Plans_Binder.dwg" nil)(princ)
^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (getvar "roamablerootprefix")"Support" )(chr 92) "Express")(princ))
|;

 

This handy macro prompts to open a drawing in the current folder:

^C^C^P(vla-activate(vla-open (vla-get-documents (vlax-get-acad-object))(findfile(getfiled "Select File" (getvar 'dwgprefix) "dwg" ) :vlax-false))

 

Lee's code does a lot of cool stuff I've never completely figured out:

  (LM:Open  (strcat (chr 47) "n," (chr 47) "e, " (chr 47) "root, " (chr 92) (chr 92) "Pubworks" (chr 92) "Sys2" (chr 92) "USERS" (chr 92) "ENGDESGN" (chr 92) (getenv "USERNAME")))
 (LM:Open  (strcat (chr 92) (chr 92) "Pubworks" (chr 92) "Sys2" (chr 92) "USERS" (chr 92) "ENGDESGN" (chr 92) (getenv "USERNAME")))
  File Selected by the User:   (LM:Open (getfiled "Select File to Open" "" "" 16))
  Drawing File at a Specified Location:   (LM:Open "C:\\My Folder\\File.dwg")
  Directory:   (^C^C^P(or C:MyOpen(load "MyOpen.lsp"));LM:Open "C:/My Folder/My SubFolder")
  Directory:   ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(LM:Open "C:/Program Files/Autodesk/AutoCAD Civil 3D 2012/Help/Civil Tutorials")
  Internet Explorer:   (LM:Open 1)
  User Start Menu Programs:   (LM:Open 2)
  All Control Panel Items:   (LM:Open 3)
  the Printers Folder:   (LM:Open 4)
  My Documents Folder:   (LM:Open 5)
  My Favorites Folder:   (LM:Open 6) or (LM:Open 31)
  the Startup Folder:   (LM:Open 7)
  the Recent Items Folder:   (LM:Open 
  the SendTo Folder:   (LM:Open 9)
  the Recycle Bin:   (LM:Open 10)
  User Start Menu:   (LM:Open 11)
  My Music:   (LM:Open 13)
  My Videos:   (LM:Open 14)
  User Desktop:   (LM:Open 16)
  My Computer:   (LM:Open 17)
  the Network Folder:   (LM:Open 18)
  the Network Shortcuts Folder:   (LM:Open 19)
  the Fonts Special Folder:   (LM:Open 20)
  Windows Templates:   (LM:Open 21) or (LM:Open 45)
  Windows Start Menu:   (LM:Open 22)
  Windows Start Menu Programs:   (LM:Open 23)
  Windows Startup Folder:   (LM:Open 24) or (LM:Open 30)
  Public Desktop:   (LM:Open 25)
  User Roaming Folder:   (LM:Open 26)
  Printer Shortcuts Folder:   (LM:Open 27)
  User AppData Local Folder:   (LM:Open 28)
  User Startup Folder:   (LM:Open 29)
  Temporary Internet Files Folder:   (LM:Open 32)
  Cookies Folder:   (LM:Open 33)
 |;

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