TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on October 19, 2004, 09:24:05 AM
-
I am trying to read data from a dwg that is open, but may or may not be active. I am using the vla-item method to acces one of the dwg's from the documents collection, but my syntax is wrong or something. I not sure. Could you guys help me out?
;*docs* = (vla-get-documents (vlax-get-acad-object))
;document = "Y:\\Common\\Projects\\School\\0303\\index of drawings.dwg"
(vla-item *docs* document)
What am I doing wrong?
Please help me?
-
Ok
I managed to get this to work, but is there a away to not have to use strcat?
(vla-item *docs* (strcat (vl-filename-base document) ".dwg"))
-
Try this;
(setq docs (vla-get-documents (vlax-get-acad-object)))
(vlax-for dwg docs
(setq doc_lst (cons (vla-get-name dwg) doc_lst))
)
; doc_lst = ("ARC.dwg" "0104-296.dwg" "710-151.dwg")
(setq dwg1 (vla-item docs (last doc_lst)))
; dwg1 = #<VLA-OBJECT IAcadDocument 01117570>
-
The dwg is loaded into acad right?
-
Mark,
I knew I could use vlax-for I just didn't want to have to iterate through the docs because I knew the file I wanted and it is loaded.
-
I think what Mark was trying to tell is that when using VLA-ITEM by name, it should be the name without path - as returned by the document's Name property.
So your strcat and filename-base thingie would be a proper way to extract the name.
-
Thanks guys.
I appreciate the responses.
-
Also;
(setq docs (vla-get-documents (vlax-get-acad-object)))
(reverse
(vlax-for dwg docs
(setq doc_lst (cons (vla-get-name dwg) doc_lst))
)
)
; doc_lst = ("710-151.dwg" "0104-296.dwg" "ARC.dwg")
; we know we want "710-151.dwg" so how about this
(setq this_dwg (vla-item docs (vl-position "710-151.dwg" doc_lst)))
-
Ok Stig.. you lost me on that ....tis ok ... I frequently get lost .....
After looking at it a little closer I think I understand now .....
and you are correct strcat with filename-base is the short way around the problem.