TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Amsterdammed on October 11, 2010, 08:02:51 AM
-
Hello there!
I ask just to prevent inventing the wheel again.
I always work with two screens and lovepaperless working, since I travel a lot with my work. SO i always have acad running on one screen and the information i need to design on the other screen, mostly pdf. So everytime i start working i need to open all the documents related to that deg I'm working on. I thought about storing the paths of the document in the deg and open them with a lisp.
I assume others have the same demand for a thing like that and therefore the code might be written already.
Thanks in advance
Bernd
-
A nice idea - if one did not exist, I'd be willing to spend some time putting one together perhaps :-)
-
A nice idea, I am facing the same problem.
-
You can add hyperlinks to objects. Just put some objects (ie texts describing the needed documents) somewhere outside the drawing, add a hyperlink to those objects and CTRL+click - voila!
-
You can add hyperlinks to objects. Just put some objects (ie texts describing the needed documents) somewhere outside the drawing, add a hyperlink to those objects and CTRL+click - voila!
second that.
-
I though more about to open the files the first time with getfiled and store the location in non graphic data and then have a command to reopen them the next time, so no big thing at all.
-
Okay, quick questions:
Would this progy automatically open the files (all, some, or last)? ...what happens if the file doesnt exist? What happens if the files are not needed any longer (5 yrs down the road)--a persistent reactor (if you decide to go that route) would be a real pain.
-
no reactor. Dictionary and you open it on command., so no reactor needed You can show them in a list first and you select what you want to open, and of course you look if the are still there
-
like a simple list box? ...cool.
-
Like a command to store open files, then write those paths to xdata. Then a command to pull that info into a listbox for retrieval. Sounds like a good idea.
-
a command to open the files in the first place wit getfiled, so you already have the path. then sore it and get it back with a listbox to select
-
Quickly scribbled together:
(defun c:docset ( / file lst )
(vl-load-com)
;; © Lee Mac 2010
(if
(while (setq file (getfiled "Select File to Add to Drawing" (cond ( file (vl-filename-directory file) ) ( "" )) "" 16))
(setq lst (cons file lst))
)
(vlax-ldata-put "DocManagerDocs" "docs" (acad_strlsort lst))
)
(princ)
)
(defun c:docget ( / _OpenFiles data )
(vl-load-com)
;; © Lee Mac 2010
(defun _OpenFiles ( files / Shell )
(setq Shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
(mapcar
(function
(lambda ( file )
(if
(vl-catch-all-error-p
(vl-catch-all-apply
(function vlax-invoke) (list Shell 'Open file)
)
)
(princ (strcat "** Error Opening: " file " **"))
)
)
)
files
)
(vlax-release-object Shell)
)
(if (setq data (vlax-ldata-get "DocManagerDocs" "docs"))
(_OpenFiles
(vlax-ldata-put "DocManagerDocs" "docs"
(vl-remove-if-not 'findfile data)
)
)
)
(princ)
)
DocSet, stores filename data in drawing dictionary, continuous file selection prompts until user hits cancel.
DocGet, opens stored files.
I'm sure it could be improved upon,
Lee
-
Lee, it boms here thus:
Command: appload
docset.lsp successfully loaded.
Command: ; error: bad argument type: numberp: nil
Steve
-
I can't seem to reproduce that Steve, furthermore, the code doesn't use any functions which are supplied predominantly with numbers, so I'm a little perplexed at that :-(
-
It works with no problem here....
thanks!!
-
You're welcome Bernd, it was just a sketch code of the ideas expressed in the thread, I'm sure it could be greatly improved upon :-)
-
Lee, my fault somewhere...
copied it again and loaded it into vanilla drawing and presto !!!!!!!!!
sorry, should have investigated further before pulling the panic chain...
Steve
-
No worries Steve 8-)
-
Now the next thing would be (but here you need a reactor for and i don't like them) to close the docs once you close the dwg......
-
Now the next thing would be (but here you need a reactor for and i don't like them) to close the docs once you close the dwg......
OpenDCL - Modeless Dialog - OnDocActivated (fires when closing or switching documents)
EnteringNoDocState (just what it says)
Dialog could be used as a GUI or made invisible to just utilize the Events.
just a thought.
jb
-
not just a thought, burt a good one :-)
-
OK, so I got sucked into a challenge and now I can't back out!
I haven't done dictionary stuff in a while: I'm attempting to store a list of drawing names but can't seem to figure it out. (cons 3 dwgList) returns (3 "dwg1" "dwg2") and errors while entmaking.
Lee, I saw you used ldata: I stay as far away from that as possible. I don't know if they fixed that but I had a slew of drawings corrupted back in 2004 thanks to Ldata (so did a lot of other people).
So whats the best way to store associated drawings?
Oh, a little teaser:
(http://img838.imageshack.us/img838/743/teasers.gif)
-
You could store them as Xrecords within a custom dictionary within the drawings.
-
Lee, I saw you used ldata: I stay as far away from that as possible. I don't know if they fixed that but I had a slew of drawings corrupted back in 2004 thanks to Ldata (so did a lot of other people).
Oh right - that's news to me, thanks James. I see quite a few other guys here use LData, so I thought it might be the way to go :-)
-
Tim, that's what I'm trying to do. I get caught up with:
(cons 3 dwgList) returns (3 "dwg1" "dwg2") and errors while entmaking.
Lee, maybe they fixed it - but once burned . . ..
Thanks for any help!
-
I find data dictionaries and XRecords easier to manage through (vla-...), if that helps. The "collection" nature of the dictionary makes it a little easier to follow than with individual DXF dotted pairs.
-
Tim, that's what I'm trying to do. I get caught up with:
(cons 3 dwgList) returns (3 "dwg1" "dwg2") and errors while entmaking.
Lee, maybe they fixed it - but once burned . . ..
Thanks for any help!
Maybe this by MP will help.
[ http://www.theswamp.org/index.php?topic=5003.0 ]
-
Great thread - thanks Tim for the link (and many thanks to MP for the explanations).
-
Ok, I guess I'll punt:
(cons 3 dwglist)
returns
(3 . "Drawing1.dwg;Drawing2.dwg;Drawing3.dwg")<-- note this is one string, the files seperated by a smi-colon. I'll parse the string that way.
See what I'm getting at?
if dwglist were a list of strings: (setq dwgList(list "Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg"))
I am unable to create the proper assosiation with (cons 3 dwgList):
That returns (3 "Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg")
??
-
What about a list?
eg.
(cons 3 (list dwglist))
-
I'm pretty inexperienced at using XRecords, but here are the options I would consider, assuming the filenames are in a list:
(cons <integer> (vl-prin1-to-string filenamelist))
Then, to read it back:
(read (cdr (assoc <integer> <XRecordData>)))
Or, using data delimiters (as you mention, semi-colons perhaps)
(cons <integer> "filename;filename;filename")
But, in my inexperience with XRecords, I myself have a few questions - what <integer> should be used? 0-9 or any other integer accepting a string argument? (referring to DXF Types here (http://autodesk.com/techpubs/autocad/acad2000/dxf/group_code_value_types_dxf_01.htm)).
Also, could using multiple entries be an option? (is this allowed?)
Lee
-
Thanks Alan / Lee,
I solved it with a pass through a string parser: lots more to do, can't get hung up on one thing! :lol:
-
Thanks Alan,
I solved with a pass through a string parser: lots more to do, can't get hung up on one thing! :lol:
Right on; just an attempt to avoid having to parse to and from a string.
-
What about a list?
eg.
(cons 3 (list dwglist))
Can DXF 3 accept a list though? Can any DXF integer accept a list other than that of a 2/3D point?
I thought 0-9 could only take strings.
-
What about a list?
eg.
(cons 3 (list dwglist))
Can DXF 3 accept a list though? Can any DXF integer accept a list other than that of a 2/3D point?
I thought 0-9 could only take strings.
Crap, good point.
-
Theres a couple of ways I would try it. The first would be to use multiple XRecords with keys of "Doc1", "Doc2", through "Doc(n)" to allow later iteration, each with a single ( 3 . "DocPathHere") element. The other would be to have a single "MyLinkedDocs" XRecord with multiple ( 3 . "DocPathHere1" ) ( 3 . "DocPathHere2" ) ( 3 . "DocPathHereN" ) elements, each pointing to a single file. You could then pull all "3" prefixed items from the assoc list for later processing. If needed they could be surrounded by a DXF 102 group to localize them.
The choice of DXF code depends on whats being stored; 3 is good for a path name, but if multiple text items were being stored I would consider using unique codes from the 300-309 sequence.
-
Also, could using multiple entries be an option? (is this allowed?)
The other would be to have a single "MyLinkedDocs" XRecord with multiple ( 3 . "DocPathHere1" ) ( 3 . "DocPathHere2" ) ( 3 . "DocPathHereN" ) elements, each pointing to a single file. You could then pull all "3" prefixed items from the assoc list for later processing. If needed they could be surrounded by a DXF 102 group to localize them.
Question answered, thanks mate :-)
-
No problem. Because the data inside the XRecords doesn't have a keyed index I tend to get lots of XRecords each with a little bit of data. Unique DXF codes can make it easier but since there are only so many to choose from its easy to "run out". That means the software must interpret the order of data and anything that modifies the list must take the order into account.
-
James,
See if you can use these in conjuncture with what MP did in the other post. It seems to work for me.
(defun UpdateDrawingList ( dwgList / Dict )
(setq Dict (GetOrAddDict (namedobjdict) "AssociatedDrawings"))
(foreach dwg dwgList
(AddOrReplaceXrec Dict (vl-filename-base dwg) (list (cons 1 dwg)))
)
)
;---------------------------------------------------------
(defun GetDrawingList ( / Data DwgList )
(setq Data (entget (GetOrAddDict (namedobjdict) "AssociatedDrawings")))
(while (setq Data (member (assoc 3 Data) Data))
(setq DwgList (cons (cdr (assoc 1 (entget (cdadr Data)))) DwgList))
(setq Data (cdr Data))
)
DwgList
)
;---------------------------------------------------------
(defun RemoveDrawing ( path / Dict Data Name )
(setq Dict (GetOrAddDict (namedobjdict) "AssociatedDrawings"))
(if
(and
(setq Data (dictsearch Dict (setq Name (vl-filename-base path))))
(= (strcase (cdr (assoc 1 Data))) (strcase path))
)
(dictremove Dict Name)
)
)
-
I have a App that is .NET that is similar, I could strip it down because you would select the project then it grouped it by drawing type(1-lines, details, ets) and listed the file name and drawing name in title block. And would let you choose how many recent projects to show. They have a extra computer on the network that does not get used much so I added a app that runs that with a filesystemwatcher to keep up if drawings are deleted or moved.
Come to think of it it would be easy to create a winform where you select the project and it would all drawings and pdf's for you.
If you need it let me know.
Sorry it gets lonley over at the NET forum and watching all of you constantly posting cool applications.
-
Sorry it gets lonley over at the NET forum and watching all of you constantly posting cool applications.
Darkside isn't all that they promised, eh? Since you asked nice you come back . . . :wink: