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

File open problem

4 REPLIES 4
Reply
Message 1 of 5
schumi
388 Views, 4 Replies

File open problem

Hi All,
I know lisp little bit but I am new to vlisp.

I am writing a LISP routine which is converting wblock (saved as .dwg) in slide files. The folders for slide files and drawing files are different.

currently I am facing problem while opening wblock (.dwg) file.

I have written "(vla-activate(vla-open (vla-get-documents (vlax-get-acad-object)) (strcat "d:/drawings/" temp3)))"

my code fails at this line.
I am attaching my code below please help me.


my code

(defun c:test ()

(vl-load-com)

(setvar "filedia" 0)

(setq dwg_list (vl-directory-files "D:\\Drawings" nil nil))
(setq sld_list (vl-directory-files "D:\\Slides" nil nil))

(setq dwg_list_len (vl-list-length dwg_list))
(setq sld_list_len (vl-list-length sld_list))

(setq temp1 (cdr(cdr dwg_list)))
(setq temp2 (cdr(cdr sld_list)))

(setq temp 0)
(setq count 0)
(setq bp '(0 0))

(while (< temp dwg_list_len)

(setq temp3 (car temp1))
(setq temp5 (vl-filename-base temp3))
(setq temp6 (strcat temp5 ".sld"))


(while(< count sld_list_len)
(setq temp4 (car temp2))

(if (/= temp4 temp6)
(progn
;(setq temp1 (cdr temp1))
(vla-activate(vla-open (vla-get-documents (vlax-get-acad-object)) (strcat "d:/drawings/" temp3)))
(command "zoom" "e" "")
(setq ent (entlast))
(command "scale" "all" "" bp "" 1 "")
(command "zoom" "e" "")
(command "mslide" (strcat "d:/slides/" temp5))
(setq temp (+ temp 1))
(setq count (+ count 1))
(setq temp2 (cdr temp2))

)


)

(setq count (+ count 1))
(setq temp2 (cdr temp2))

)


)

)
4 REPLIES 4
Message 2 of 5
mkweaver01
in reply to: schumi

I don't see any way to get your code to work directly. Not that there's anything wrong with your code, but rather a limitation in the way lisp works.

Each drawing has it's own lisp environment. That's why you can't access a lisp variable from one drawing in another drawing. I suspect your code stops as soon as it activates the second drawing. This is because the active drawing hasn't had any commands issued (or lisp routines run) and your lisp routine can't run in the first drawing because that drawing is no longer active.
I can see only one way to skin this cat with lisp. you will have to write a script with your lisp routine then have that lisp routine start the script. Finally, you will want the script to close the file so you end up back in your original drawing. At this point, the original lisp routine should resume.

Personally, my approach would be to do the entire exercise with a script.

Hope that helps,
Mike Weaver
Message 3 of 5
schumi
in reply to: schumi

Thanks Mike !
It's a valuable information. I thought my logic or syntax is wrong.

I will try it by script. Can I do it through VBA? Please guide me.

Thanks in Advance.

Sumit
Message 4 of 5
mkweaver01
in reply to: schumi

While I'm sure this can be done with a script, I'm not as certain about VBA. I think it can be done with VBA, but would have to do some testing to be sure.
Message 5 of 5
Anonymous
in reply to: schumi

You might trying inserting the drawing into the current drawing, zooming,
etc, mslide, then erasing all and continuing to next drawing.

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

Post to forums  

Autodesk Design & Make Report

”Boost