Jump to content

Repeat to write a DSD file, if find an specific Layoutname


Manuel_Kunde

Recommended Posts

Hi all, below is a snippet of a lisp that writes a custom dsd for the current layout (ctab). So far it works, and creates me a PDF of the current layout.

My problem is that I want to run this section for each layout that contains the layout name *Plan*.

Does anyone have any idea on how I can incorporate this repetition?

 

      (write-line (strcat "[DWF6Sheet:" (getvar "DWGNAME") "-" (getvar "ctab") "]") file)
      
      (write-line (strcat "DWG=" (getvar "DWGPREFIX") (getvar "DWGNAME") ".dwg") file)
      (write-line (strcat "Layout=" (getvar "ctab")) file)
      (write-line (strcat "Setup=" ) file)
      (write-line (strcat "OriginalSheetPath=" (getvar "DWGPREFIX") (getvar "DWGNAME") ".dwg") file)
      (write-line (strcat "Has Plot Port=0") file)
        
      (write-line (strcat "Has3DDWF=0") file)

 

Edited by Manuel_Kunde
Link to comment
Share on other sites

Here's an example:

(setq dwp (getvar 'dwgprefix)
      dwg (getvar 'dwgname)
)
(foreach lyt (layoutlist)
    (if (wcmatch (strcase lyt t) "*plan*")
        (write-line
            (strcat
                "[DWF6Sheet:" dwg "-" lyt "]"
                "\nDWG=" dwp dwg ".dwg"
                "\nLayout=" lyt
                "\nSetup="
                "\nOriginalSheetPath=" dwp dwg ".dwg"
                "\nHas Plot Port=0"
                "\nHas3DDWF=0"
            )
            file
        )
    )
)

 

  • Like 1
Link to comment
Share on other sites

Thanks Lee, behind the scenes this  was provided to Manuel. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/publish-dsd-file/td-p/1350729

 

Needs to merge the 2. 

 


(defun c:makedsd (/ file layouts_to_plot NumTabs OldFda )
(setq OldFda (getvar "FILEDIA"))
(setvar "FILEDIA" 0)
  
;;;(setq layouts_to_plot (dos_multilist "Create Multi-sheet DWF file" "Select drawings" (layoutlist)))
(setq NumTabs (length layouts_to_plot));Number of tabs selected

(setq pathtxt (strcat (getvar "dwgprefix") "newfile.dsd"))
(setq file (open (strcat (getvar "dwgprefix") "newfile.dsd") "w"))
  
(write-line "[DWF6Version]" file)
(write-line  "Ver=1" file)
(write-line  "[DWF6MinorVersion]" file)
(write-line  "MinorVer=1" file)
   
(write-line (strcat "[DWF6Sheet:"(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))"-" (getvar "ctab") "]")file)
(write-line (strcat "DWG=" (getvar "dwgprefix")(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".dwg")file)
(write-line (strcat "Layout=" (getvar "ctab") )file)
(write-line (strcat "Setup=" )file)
(write-line (strcat "OriginalSheetPath=" (strcat(getvar "dwgprefix")(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))".dwg") )file)
(write-line (strcat "Has Plot Port=1" )file)

  
(write-line (strcat "[Target]") file)
(write-line (strcat "Type=1" ) file)
(write-line (strcat "DWF=" (strcat(getvar "dwgprefix")(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))".dwf") )file)
(write-line (strcat "OUT="(strcat(getvar "dwgprefix")  )) file)
(write-line (strcat "PWD=" )file)

(close file)
(command "_.delay" 2000) 
(command "-Publish" pathtxt )
(setvar "FILEDIA" OldFda)

  (startapp "explorer /e," (getvar "dwgprefix"))
(princ)
);defun


     

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 8/21/2021 at 4:55 AM, BIGAL said:

Thanks Lee, behind the scenes this  was provided to Manuel. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/publish-dsd-file/td-p/1350729

 

Needs to merge the 2. 

 

 

 

So far the Lisp works fine. However, I noticed that the layouts are not written to the DSD file in series,  left to right, but randomly.

Is it possible to set the order somehow?

Link to comment
Share on other sites

9 minutes ago, confutatis said:

The layout list is not randomly, but in alphabetical order. What do you need, to want the layouts from left to right?

 

Yes that is the problem with the alphabetical order.

I need the order in the DSD as I have the layout tabs arranged, from left to right. In this case they are not alphabetical.

Link to comment
Share on other sites

You can use the ActiveX taborder property to sort the layouts by the order in which they appear in the drawing, e.g.:

 

(
    (lambda ( / dwg dwp idx lst )
        (setq dwp (getvar 'dwgprefix)
              dwg (getvar 'dwgname)
        )
        (vlax-for lyt (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
            (if (wcmatch (strcase (vla-get-name lyt) t) "*plan*")
                (setq lst (cons (vla-get-name     lyt) lst)
                      idx (cons (vla-get-taborder lyt) idx)
                )
            )
        )
        (foreach n (vl-sort-i idx '<)
            (setq lyt (nth n lst))
            (write-line
                (strcat
                    "[DWF6Sheet:" dwg "-" lyt "]"
                    "\nDWG=" dwp dwg ".dwg"
                    "\nLayout=" lyt
                    "\nSetup="
                    "\nOriginalSheetPath=" dwp dwg ".dwg"
                    "\nHas Plot Port=0"
                    "\nHas3DDWF=0"
                )
                file
            )
        )
    )
)

 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

15 hours ago, Lee Mac said:

You can use the ActiveX taborder property to sort the layouts by the order in which they appear in the drawing, e.g.:

 

I wouldn't have figured it out myself. Thanks a lot!

Link to comment
Share on other sites

...taborder...here's another feature I didn't know about. You think you know enough and then you find out you're an ignorant. It's really true: the more you know, the less you know....

Link to comment
Share on other sites

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