Jump to content

Recommended Posts

Posted

I have multiple (100+) drawings that have borders in either model or layout but not both. Its a mixed bag every time. Unfortunately that's the terrible system that my client has and there's nothing I can do to change it. I need to plot them in the "space" where the border is located. I make it a habit to save the dwgs in the correct space when closing them and so it would be very beneficial to just create a .dsd file that I can load in with the last saved space when I go to publish. Then I can import my page setups etc. I would greatly appreciate any help! This has proven to be a challenge and a half for someone who is newer to LISP 😅

 

I'll include a routine I found that is similar.

I would just need the options to select multiple dwgs and only include the last saved Layout (Model counts). Thanks!

 

(defun c:makedsd (/ file layouts_to_plot NumTabs OldFda )
(setq OldFda (getvar "FILEDIA"))
(setvar "FILEDIA" 0)
  
(setq NumTabs (length layouts_to_plot))

(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

 

 

Posted (edited)

.dsd isn't a file type I know or have used, why that one?

 

Are you able to go a bit simpler, instead of creating an external file create a little LISP that assesses the drawing and which space the border details are saved in and then publish from there? You can share that LISP with colleagues who can do the same thing without needing access to the external file?

 

But back to the original question, instead or 'w'riting to the text file, check the file exists and then 'A'ppend to the file

 

 

 

LISP something like this to get where the border is located. Assuming that the border is / contains a unique block (user specified and hard coded in the LISP... it is possible to use wildcards if say border blocks are "A1 Border" "A2 Border" and so on

 

(defun c:BorderSpace ( / BorderName MyBorder BorderSpace)

  (setq BorderName "My_Border_Block_Name")   ;USer defined border block name

  (setq MyBorder (ssget "_X" (list (cons 2 BorderName))))  ;; search drawing for the border block

;; Add here check in in case there is no block, BorderName inserted ;;

  (setq BorderSpace (cdr (assoc 410 (entget (ssname MyBorder 0)))))  ; get the 'space' birder block is inserted in


;; Do plotting / publish routine from here ;;
;;.......

)

 

You can add the details from your LISP to find file locations and so on as required,

Edited by Steven P
  • Like 1
Posted

Thanks! Learn something every day

Posted

Steven thanks for your reply!

Unfortunately I had already thought about multiple directions to take this and searching for block names, although technically possible, would be a bit too cumbersome in this case as block names vary. It would be most beneficial to use something that takes less time than populating the publish dialogue box with the drawings in the proper layouts manually. Therefore, creating and populating a dsd would be the way to go in my opinion.

I just can't seem to wrap my head around how to code the "last saved space" for a dwg I guess that would be the most important puzzle piece I need to make a working LISP.

Posted

Still sticking with the LISP idea and not an external file, is there anything consistent with all the blocks?

 

Simple example, in ours we might have "A0Title", "A1Title", "A2Title".... and so on however they all have an attribute inside each block "Drawing_Number" (amongst others), I think consistent with a lot of client title blocks "REV" is very common to a lot.... if you can find one that is unique to the borders then you can search blocks till you find the attribute and then the space as above:

 

(defun c:FilenameTag ( / MyEnt Att TagName BorderSpace acount )


  (setq FileNameTag "My_Border_Block_Name")   ;User defined constant tag name


  (setq BlockSS (ssget "_X" (list (cons 0 "INSERT"))))  ;; search drawing for blocks in all spaces
;;Note might be quicker to search the database directly rather than ssget + picks up hidden blocks

  (setq acount 0)                                       ;; A counter
  (while (< acount (sslength MyBorder))                 ;; Loop through blocks
    (setq MyEnt (ssname BlockSS acount))                ;; Block Entity name, nth block in selection set
    (foreach Att (vlax-invoke (vlax-ename->vla-object MyEnt) 'GetAttributes ) ;; Loop through block attributes
      (setq TagName (vla-get-TagString Att))            ;; Real world tag name
      (if (= (strcase TagName) (strcase FileNameTag) )  ;; If real world tag name is search term above
        (setq BorderSpace (cdr (assoc 410 (entget MyEnt)))) ;; Get the space
      ) ; end if
    ) ; end for each
    (setq acount (+ acount 1))
  ) ; end while

    BorderSpace  ;; Return which space the block is in
)

 

With a lot of blocks and a lot of attributes this can be relatively slow but slower than opening each drawing, running the other LISP, saving the temporary file, maybe not?

 

With similar thinking, you might search through the tags to get maybe the drawing number, using (vla-get-TextString Att) to get the text strings.

 

 

 

Above might not work on LT (Limited LISP ability) - if it doesn't can be changed around using Lee Macs Get Attribute Value 'Vannila Lisp' example

Posted

"last saved space" What about (getvar 'ctab).

 

Do they really have that many title blocks that you can not make a list to match ? I have code that looks for say 8 different title blocks and plots them.

 

 

 

 

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