Author Topic: How can autorun file ?  (Read 2502 times)

0 Members and 1 Guest are viewing this topic.

new_mem

  • Newt
  • Posts: 67
How can autorun file ?
« on: June 11, 2016, 04:03:12 AM »
Hello

Can someone tell me: autorun this file following attach then ACAD_DGNLINESTYLECOMP, and purge via lisp.
I mean:
(defun purge_pdi (/ fna)
  (vl-load-com)
  (if (setq fna (findfile "@PurgeDictionaryItems[PDI].fas"))
    (load fna)
    );if
  (C:PDI)
  (command "ACAD_DGNLINESTYLECOMP")
  (command "-purge" "all" "*" "N" "")
  ;(command "PDI" "ACAD_DGNLINESTYLECOMP")
  )
It not graphis screen text in command line to PDI command. How can fix it !

Thank you.
« Last Edit: June 11, 2016, 03:48:31 PM by new_mem »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: How can autorun file ?
« Reply #1 on: June 11, 2016, 06:26:44 PM »
Sorry, I don't understand your questionn.
Can you ask in a different way ?

//------------

What is (C:PDI) ??

//------------

I don't think many people will load your .fas file without knowing exactly what's in it ...  I won't.

//------------

What do you mean by 'autorun' ... do you want it to load and run for each new drawing ??
Or to run each time it is loaded ??

//------------

Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #2 on: June 11, 2016, 10:35:53 PM »
Okey thanks for answer.

For all drawing open i mean

1. Load PDI.fas
2. Command PDI
3. Select ACAD_DGNLINESTYLECOMP
4. Purge.
5. Save
6. Close


new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #3 on: June 15, 2016, 06:35:57 AM »
Heiz , Lee Mac

I found your code: ObjectDBXWrappe

And modify with purge.

(defun c:test2 (/ remove_dict1 doc)
  (defun remove_dict1 ()
  (if (dictsearch (namedobjdict) "ACAD_DGNLINESTYLECOMP")
    (dictremove (namedobjdict) "ACAD_DGNLINESTYLECOMP")
    )
  (setq doc (vla-get-activedocument (vlax-get-acad-object))) 
  (repeat 3 (vla-purgeall doc))
  (vla-saveas doc)
  );;
  (LM:ODBX 'remove_dict1 nil t)
  (princ)
  )

But still error.
Can you fix it.?
Thanks

ChrisCarlson

  • Guest
Re: How can autorun file ?
« Reply #4 on: June 15, 2016, 09:36:36 AM »
See your other thread.

new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #5 on: June 15, 2016, 10:06:51 AM »
Hi, i am trying learn use code browse.

I fixed my problem by write to acaddoc.lsp line "remove_dict".

So i post code: (LM:ODBX 'remove_dict1 nil t) and ask how to fix.

I think ask to faster to fix problem. Do you think so ?

ChrisCarlson

  • Guest
Re: How can autorun file ?
« Reply #6 on: June 15, 2016, 10:15:31 AM »
You're passing too many arguments somewhere. Setup breakpoints and see what line is erroring out.

Based on the description of lee's object wrapper, I don't think it should be used in this case.

Quote
Provides a shell through which a user may evaluate a supplied function on every drawing in a given list of drawing filenames or on all drawings residing within a selected directory.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How can autorun file ?
« Reply #7 on: June 15, 2016, 12:13:17 PM »
Heiz , Lee Mac

I found your code: ObjectDBXWrappe

And modify with purge.

(defun c:test2 (/ remove_dict1 doc)
  (defun remove_dict1 ()
  (if (dictsearch (namedobjdict) "ACAD_DGNLINESTYLECOMP")
    (dictremove (namedobjdict) "ACAD_DGNLINESTYLECOMP")
    )
  (setq doc (vla-get-activedocument (vlax-get-acad-object))) 
  (repeat 3 (vla-purgeall doc))
  (vla-saveas doc)
  );;
  (LM:ODBX 'remove_dict1 nil t)
  (princ)
  )

But still error.
Can you fix it.?
Thanks

Firstly, note that the function argument (in your case this argument is 'remove_dict1') for my ObjectDBX Wrapper should accept a single argument corresponding to the ActiveX Document object for each drawing processed. However, as noted within the program description for my ObjectDBX Wrapper, the supplied function must also be 'compatible' with ObjectDBX, as such, all operations must be derived from the ActiveX Document object.

new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #8 on: June 16, 2016, 01:33:06 PM »
Okey Lee,

1. I mean use ActiveX to learn, my problem fixed by script.
2.I changed ename to vla object
(defun remove_dict (/ dicts dict)
  (setq dicts (vlax-get (vla-get-activedocument (vlax-get-acad-object)) 'dictionaries))
  (setq dict (vlax-invoke dicts 'item "ACAD_DGNLINESTYLECOMP"))
  (vla-delete dict)
  (repeat 3 (vla-purgeall (vla-get-activedocument (vlax-get-acad-object))))
  (vla-save (vla-get-activedocument (vlax-get-acad-object)))
)

3. What is single argument corresponding to the ActiveX Document object  .?
Maybe single command in one drawing ?

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How can autorun file ?
« Reply #9 on: June 16, 2016, 04:05:00 PM »
Code: [Select]
(defun remove_dict (/ dicts dict)
  (setq dicts (vlax-get (vla-get-activedocument (vlax-get-acad-object)) 'dictionaries))
  (setq dict (vlax-invoke dicts 'item "ACAD_DGNLINESTYLECOMP"))
  (vla-delete dict)
  (repeat 3 (vla-purgeall (vla-get-activedocument (vlax-get-acad-object))))
  (vla-save (vla-get-activedocument (vlax-get-acad-object)))
)

3. What is single argument corresponding to the ActiveX Document object  .?

Your code is referencing the ActiveDocument - this should be replaced with a parameter which is supplied to the function by my ObjectDBX Wrapper function for each drawing processed, for example:
Code - Auto/Visual Lisp: [Select]
  1. (defun remove_dict ( doc / dic )
  2.     (if (setq dic (catchapply 'vla-item (list (vla-get-dictionaries doc) "acad_dgnlinestylecomp")))
  3.         (catchapply 'vla-delete (list dic))
  4.     )
  5.     (repeat 3 (vla-purgeall doc))
  6. )
  7. (defun catchapply ( fun arg / rtn )
  8.     (if (not (vl-catch-all-error-p (setq rtn (vl-catch-all-apply fun arg)))) rtn)
  9. )

The above is untested however.

Note that the save operation should be excluded as my ObjectDBX Wrapper function will perform this operation if the last argument is non-nil.

new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #10 on: June 16, 2016, 07:11:28 PM »
Ahhh, i understood

single argument: ( doc / dic ) --->dic

Through your code I was learning more about. That is clear.

Thank you so much Lee.  :smitten:

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How can autorun file ?
« Reply #11 on: June 17, 2016, 07:57:22 AM »
single argument: ( doc / dic ) --->dic

Through your code I was learning more about. That is clear.

Thank you so much Lee.  :smitten:

You're welcome -

But just to clarify, 'doc' is the argument which is assigned the ActiveX Document object when the function is evaluated by my ObjectDBX Wrapper; 'dic' is the local variable which stores the acad_dgnlinestylecomp dictionary.

new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #12 on: June 17, 2016, 09:40:04 AM »
But just to clarify, 'doc' is the argument which is assigned the ActiveX Document object when the function is evaluated by my ObjectDBX Wrapper; 'dic' is the local variable which stores the acad_dgnlinestylecomp dictionary.

Okey Lee,

I already understand. Alway 'doc' and creat funtion assigned the ActiveX Document object (layer, layout, dim, or bla bla............)

Thanks.

new_mem

  • Newt
  • Posts: 67
Re: How can autorun file ?
« Reply #13 on: June 17, 2016, 10:30:43 AM »
Lee,

i am trying example with you funtion:

(defun c:test ( / doc clyt paper StyleSheet ConfigName)
  (vl-load-com)
  (setq   doc  (vla-get-activedocument (vlax-get-acad-object)))
  (setq clyt  (vla-get-activelayout doc))
  (setq paper (vla-get-CanonicalMediaName clyt))
  (setq StyleSheet  (vla-get-StyleSheet clyt))
  (setq ConfigName  (vla-get-ConfigName clyt))
 
  (LM:ODBX 'put_configPLT nil t)
 
  (defun put_configPLT (doc / ) ;
    (vlax-for layout (vla-get-layouts doc)
      (if (/= (getvar "ctab") "Model")
   (progn
     (vla-put-CanonicalMediaName layout paper)
     (vla-put-StyleSheet layout StyleSheet)
     (vla-put-ConfigName layout ConfigName)
     );progn
   );if
      );
    );defun1

Question:
1.Why drawing 1 ok, but drawing 2 not run.
2. Where is area plot current layout in drawing opening ? or copy all setting cur layout to all drawing .

« Last Edit: June 17, 2016, 12:01:41 PM by new_mem »