Author Topic: What am I doing wrong?  (Read 3283 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
What am I doing wrong?
« 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?
Code: [Select]
;*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?

whdjr

  • Guest
What am I doing wrong?
« Reply #1 on: October 19, 2004, 09:38:00 AM »
Ok
I managed to get this to work, but is there a away to not have to use strcat?

Quote
(vla-item *docs* (strcat (vl-filename-base document) ".dwg"))

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
What am I doing wrong?
« Reply #2 on: October 19, 2004, 09:38:32 AM »
Try this;
Code: [Select]

(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>
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
What am I doing wrong?
« Reply #3 on: October 19, 2004, 09:40:22 AM »
The dwg is loaded into acad right?
TheSwamp.org  (serving the CAD community since 2003)

whdjr

  • Guest
What am I doing wrong?
« Reply #4 on: October 19, 2004, 09:44:33 AM »
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.

SMadsen

  • Guest
What am I doing wrong?
« Reply #5 on: October 19, 2004, 09:57:20 AM »
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.

whdjr

  • Guest
What am I doing wrong?
« Reply #6 on: October 19, 2004, 10:02:37 AM »
Thanks guys.

I appreciate the responses.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
What am I doing wrong?
« Reply #7 on: October 19, 2004, 10:07:20 AM »
Also;
Code: [Select]

(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)))
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
What am I doing wrong?
« Reply #8 on: October 19, 2004, 10:13:53 AM »
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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie