Jump to content

Recommended Posts

Posted

Hi, I'm new here. I want a lisp file which automatically copy visible content of a drawing and save it to a new dwg file. Is it possible? Please help me.

Posted

Welcome to Cadtutor .

 

wblock command help at all ?

Posted

Thanks for your reply. But It will only export the content in Model not in Layout. I want to export both

Posted (edited)
(defun c:test ( / nfn app fn )
 (vl-load-com)
 (if (setq nfn (getfiled "Choose directory" "c:\\" "dwg" 1))
   (progn
     (setq fn 
       (vla-get-fullname 
         (setq *acdoc*
           (cond ( *acdoc* )
             ( (vla-get-activedocument (vlax-get-acad-object)) )
           )
         )
       )
     ) (vla-saveas *acdoc* nfn)
     (vla-save *acdoc*) (vla-saveas *acdoc* fn) (vla-save *acdoc*)
     (cond
       ( (findfile "c:\\Windows\\media\\tada.wav")
         (setq app (vlax-create-object "WMPlayer.OCX.7"))
         (vlax-invoke (vlax-get app 'CurrentPlaylist) 'Appenditem
           (vlax-invoke app 'NewMedia "c:\\Windows\\media\\tada.wav")
         ) (vlax-invoke (vlax-get app 'controls) 'play)
         (vlax-release-object app) (gc)
       )
     ) 
     (startapp "explorer" (vl-filename-directory nfn))
   )
 ) (princ)
)

Edited by Lt Dan's legs
boredom
Posted

I've updated my code above. I'm assuming you wanted to make a backup of the current drawing..

Posted

Thanks all-of you. But they does not fulfill my need. I actually want a lisp which copy all the visible content in the model as well as in Layout (but not that layers and contents which are turned off) and save it to a another drawing.

Posted (edited)

What about making a list of all Frozen/Off layers, use that list to delete all objects that falls onto that list then wblock

Programmatically that is. :)

 

 

Well? I'm ready to write the code for you only if you tell me the filename format or folder path

 

Have time to play

(defun c:Leaveus ( / aDoc Layers path laylist)
       (setvar 'Expert 5)
      (setq aDoc (vla-get-activedocument (vlax-get-acad-object))
             laylist nil
             path (strcat (getvar 'dwgprefix) "CopyOfFiles" "\\"))
    [i] ;<-- "CopyOfFiles" Folder name for Visible drawings
[/i]         (vlax-for       
       itm
          (vla-get-layers aDoc)
      (if (or (eq (vla-get-Freeze itm) :vlax-true)
              (eq (vla-get-LayerOn itm) :vlax-false))
            (setq laylist (cons (vla-get-name itm) laylist))))
       (vl-mkdir path)
      (if (and (= (getvar 'Dwgtitled) 1) laylist)
           (progn
              [b] (command "_undo" "Mark")  
[/b]        (vlax-for layout (vla-get-layouts adoc)
               (vlax-for ent (vla-get-block layout) 
         (if (member (vla-get-layer ent) laylist)
                        (vla-delete ent))))
               (command [b]"-wblock"[/b] (strcat   path (getvar 'Dwgname)) "*")
              [b] (command "_undo" "Back")
[/b]                )
              )
(princ)
      )

HTH

Edited by pBe

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...