Jump to content

Recommended Posts

Posted

All,

 

I have two preliminary routines called CA (CloseAll) and PA (PrintAll) tailored for my needs as following:

 

CloseAll:

(defun C:CA()
(setvar "TILEMODE" 1)
(command "._ZOOM" "_Extents")
(command "._PURGE" "all" "*" "No")
(command "._PURGE" "all" "*" "No")
(command "._PURGE" "all" "*" "No")
(setvar "TILEMODE" 0)
(command "._MSPACE")
(command "._Grid" "_OFF")
(command "._OVERKILL" "ALL" \\P "DONE")	
(command "._PSPACE")
(command "._VPORTS" "L" "ON" "ALL" "")
(command "._ZOOM" "_Extents")
(command "._QSAVE")
(command "._CLOSE")
)

 

PrintAll:

(defun C:PA()
 (foreach x  (LAYOUTLIST)
   (setvar "CTAB" x)
   (command "-PLOT" "" "" "" "" "" "" ""))
 )

 

Above codes work perfect for a single drawing. However, I am stuck on applying them to all of my open drawings (trying to learn LSP gradually :oops:).

 

Note I don't want to 'browse' for any specific folders or drawings or load some script to do so. Instead I need to apply my code across all open drawings.

 

 

The intent is to put them both in my Startup Suite and call them whenever needed.

 

 

Attentions are appreciated in advance.

Posted

Since AutoLISP runs in the document namespace (that is, in the active drawing) you will need to use an AutoCAD Script (.scr file) if you wish to run the programs in more than one drawing.

Posted
Since AutoLISP runs in the document namespace (that is, in the active drawing) you will need to use an AutoCAD Script (.scr file) if you wish to run the programs in more than one drawing.

 

Thanks for the reply Lee.

The reason why I am pursuing such approach is, because I noticed to an option in your BFind program which gives me the pleasure of searching (let's say processing) on open drawings.

 

BFind_V2_0_1.png

 

Can you show me the pathway toward that direction maybe?

Posted

When processing all open drawings, my BFind application iterates over the ActiveX documents collection and manipulates the ActiveX properties of each document object (and objects derived from the document) whilst running in the active document namespace.

 

This is only possible to achieve using Visual LISP ActiveX properties & methods which operate only on the document object or objects derived from the document object; hence, in general it is not possible to run an arbitrary AutoLISP program on any drawing except the active drawing and instead an AutoCAD Script must be used, as stated above.

 

Furthermore, it would not be possible to convert your programs to functions which operate only on the ActiveX document object as the programs contain operations (such as zooming) which are methods of the Application object and hence cannot be applied outside of the active document, and custom commands (such as overkill) which would need to be entirely recreated using only Visual LISP.

Posted

Frankly, that was too much information for me to digest but thanks for that. At least, I realised it is not that easy as I thought. Can you refer me to more resources? I am curious to read about it more thoroughly.

Posted (edited)

here is a start list of dwg names

 

 



; THANKS TO AHANKHAH for original code
(vl-load-com)
(setq acadobject (vlax-get-Acad-Object))
(setq documentcollection (vla-get-documents acadobject))
(vlax-for <doc> documentcollection
 (if (eq "" (setq *dwg* (vla-get-fullname <doc>))) (setq *dwg* (vla-get-name <doc>))) 
 (setq *acdocs* (cons (cons (strcase *dwg*) <doc>) *acdocs*))
)
(reverse *acdocs*)
(princ *acdocs*)

Edited by BIGAL
  • 2 months later...
Posted

Since I have a similar concern, this time, I am not creating new thread for that.

 

Following post no. 4, by Lee, how can I set TILEMODE for all of open drawings? Is it possible at all? I need to set TILEMODE to "0" for all of my open drawings.

Posted

bhull1985, mate, you must have had a really bad day. I don't know how you got the implication of ignorance or disrespect from my posts.

 

First of all, thanks for the hint about Setvar. You misunderstood my question. The concern is about applying Setvar on all open drawings not the fact of using Setvar itself.

 

Secondly, no offence but, would you please let Lee talks on his behalf? I have always appreciated his kind favour in all forums via direct replies, private messages or sometimes his twitter account. Person who is generously sharing his LSP collection with others for free while others sell their '2+2 = 4' lisp for $8.99, clearly intend to share his knowledge nothing whatsoever.

 

His comment was the final verdict for me not to pursuit my previous approach try applying that piece of code to all open drawings. That's why topic went silent from my side.

 

However, having the same question, I want to know how to get following code iterate through all open drawings. Not sure how to implement a ForEach for iteration. :unsure:

 

(defun c:S2L (/ OpenDwgs eachDwg)
 (setq OpenDwgs (vla-get-documents (vlax-get-acad-object)))
 (vlax-for eachDwg OpenDwgs
   (setvar "tilemode" 0)
 )
 (princ)
)

 

Now, if you don't mind, can I kindly ask to leave this 'pancake' stuff for others and myself?

Posted

Something like this perhaps.

(defun c:S2L ( / )
 (vlax-for OpenDwgs (vla-get-documents (vlax-get-acad-object))
   (vla-setvariable OpenDwgs "TILEMODE" 0)
 );; vlax-for
 (princ)
)

 

HTH

Henrique

Posted

That's it. Thank you so much.

Posted

You're welcome.

Glad I could help

 

 

Henrique

Posted

Good stuff Henrique - thanks for stepping in whilst I have been busy.

Posted
Good stuff Henrique - thanks for stepping in whilst I have been busy.

Thank you Lee. :)

Happy to help!

 

 

Henrique

  • 5 years later...
Posted

Hi Guys!

Could this way of work be used to:

1. update a block definition from one drawing to all open drawings? (by hand it is through wblock/insert or design center)

2. Attsync that block or all blocks on all open drawings?

Posted

is asked before :

 

have a block routine but some say it's rather complicated to drive so to spreak so I won't repost or refer to it , but the way my batch application works in case of mdi mode is to start a new drawing , save and close all open drawings and then reopen them and run all the scripts & commands I want. Totally dragon proof and totally don't care about the few seconds longer it takes compared to vba / odbx.

 

if you do want to use the fast lane (not sure about dynamic blocks though) the way my block routine handles it is for each block get its properties (inspoint , rotation etc) and all the attribute values , then burn them all , sorry can't help m'self , then delete them all , purge block definition , and then re-insert them one by one and transfer attribute data.

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...