Lisp - Is it possible to "paste a path" instead of clicking on folders ?

Lisp - Is it possible to "paste a path" instead of clicking on folders ?

Evalucia
Advocate Advocate
385 Views
3 Replies
Message 1 of 4

Lisp - Is it possible to "paste a path" instead of clicking on folders ?

Evalucia
Advocate
Advocate

Hi, sorry if it's a stupid question, I searched but I don't really know what words to look for.

 

A long time ago I found a lisp online that sets a certain layer to "no plot".

It works like a charm, but to select the folder where the drawings are, I need to click on a lot of folders.

Here is an example (and I haven't reached the right folder yet) :

Evalucia_1-1703024507576.png

 

I would like to know if there's a way to get a box where I could paste the path instead of clicking all the folders ?

Does it exist ?

 

I don't really know Lisp.

I tried to make some many years ago but didn't touch it since then.

 

Here is the Lisp :

;|function to to set a specific layer to NoPlot in the drawings of a
specified folder
by Jeff Mishler May 19, 2006 .... will not affect any drawings that do not
have the layer|;
(defun setlay2noplot (lyrname / *acad dwgs f folder odbx)
;;as posted the autodesk discussion customization group by Tony Tanzillo
(defun BrowseForFolder (title / sh folder parentfolder folderobject
result)
(vl-load-com)
(setq sh
(vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
)

(setq folder
(vlax-invoke-method
sh 'BrowseForFolder 0 title 0)
)
(vlax-release-object sh)

(if folder
(progn
(setq parentfolder
(vlax-get-property folder 'ParentFolder)
)
(setq FolderObject
(vlax-invoke-method
ParentFolder
'ParseName
(vlax-get-property Folder 'Title)
)
)
(setq result
(vlax-get-property FolderObject 'Path)
)
(mapcar 'vlax-release-object
(list folder parentfolder folderobject)
)
result
)
)
)
(defun getdwglist (folderlist)
(apply 'append
(mapcar '(lambda (f)
(mapcar '(lambda (name)
(strcat f "\\" name)
)
(vl-directory-files f "*.dwg" 1)
)
)
folderlist
)
)
)
(if (and (setq *acad (vlax-get-acad-object))
(setq folder (browseforfolder "Folder to modify drawings from"))
(setq dwgs (getdwglist (list folder)))
)
(progn
(setq
odbx (if (< (atoi (setq verno (substr (getvar "acadver") 1 2))) 16)
(vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument")
(vla-GetInterfaceObject
*acad
(strcat "ObjectDBX.AxDbDocument." verno)
)
)
)
(foreach dwg dwgs
(and
(not (vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(vla-open odbx dwg)
)
)
)
)
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(setq lyr (vla-item (vla-get-layers odbx) lyrname))
(vla-put-plottable lyr :vlax-false)
(vla-saveas odbx dwg)
)
)
)
)

)
)
(mapcar 'vlax-release-object (list odbx *acad))
)
)
)

(defun c:setnoplot ()
(setlay2noplot "QUESTIONS");;provide the layer name to set to no-plot here
(princ)
)

 Thank you!

0 Likes
386 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

If you want current dwg location as start point.

 

(getfiled "Select file" (getvar 'dwgprefix) "dwg" 1)

 

0 Likes
Message 3 of 4

Evalucia
Advocate
Advocate

Thank you, that would be a nice improvement.

 

Sorry for my lack of knowledge but which line should I replace with yours ?

0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

I should have used a different flag bit not 1. This will return a file name and full path, need strip dwg name of end. Can go up and down the directories.

 

 

 

(setq file (getfiled "Select file" (getvar 'dwgprefix) "dwg" 10))
(setq dir (substr file 1 (vl-string-position 92 file 0 t)))

 

Ref Subtract a file name from a path name? - AutoLISP, Visual LISP & DCL - AutoCAD Forums (cadtutor.net)

0 Likes