Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help. Pass a list of dwgs to (vl-cmdf "vbastmt" ... open readonly.

3 REPLIES 3
Reply
Message 1 of 4
mdhutchinson
313 Views, 3 Replies

Help. Pass a list of dwgs to (vl-cmdf "vbastmt" ... open readonly.

    (vl-cmdf "vbastmt" "acadapplication.documents.open \"c:/path/mydwg.dwg\",TRUE")

 

This will open the dwg file (if it exists) read only. 

... I am wanting to do this on a list of dwgs... I get syntax error... but I think I am close

 

 

(foreach dwg (list "C:/Path/dwg1" "C:/Path/dwg2" "C:/Path/dwg3")

   (vl-cmdf "vbastmt" (strcat "acadapplication.documents.open " (chr 92)(chr 34) dwg (chr 92)(chr 34) ",TRUE"))

)

 

 

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: mdhutchinson

Do you have to use VBA?
I dont have VBA in this laptop, but if your goal is to open a dwg list readonly, perhaps something like this

(foreach dwg (list "C:/Path/dwg1" "C:/Path/dwg2" "C:/Path/dwg3")
  (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat "\"" dwg "\"") :vlax-true)
  )

 

HTH
Henrique

EESignature

Message 3 of 4
mdhutchinson
in reply to: hmsilva

This might work... I just happened to think though... I wonder if the lisp would halt in it's track when the second drawing opens... since vocus would leave the drawing where it was launched.

The only other thing if a script would do this... I've ran scripts on multiple dwg files... they open fine even in SDI = 0

Message 4 of 4
hmsilva
in reply to: mdhutchinson

"I wonder if the lisp would halt in it's track when the second drawing opens... since vocus would leave the drawing where it was launched."

Using "vla-open" without "activate" the dwg, the lisp will open readonly all the dwg's in the list and return to the original dwg.

Using the "vbastmt", and you only need a to use a (chr 34) not a (chr 92) (chr 34)
i.e.
(setq dwg "C:/Path/dwg1")
(vl-cmdf "vbastmt" (strcat "acadapplication.documents.open " (chr 34) dwg (chr 34) ",TRUE"))

 

If my memory don't trick me, using "vbastmt" with a dwg list, would halt at the first opened dwg... I can't test it...

 

"The only other thing if a script would do this..."

The only way I know to open dwg's readonly from a script file, isn't a clean way, so I think it's better not to post it...


Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost