Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/10/2022 in all areas

  1. AutoCAD Map 3D Help: To Create a Customized Scale Bar Without Map 3D it would be a daunting task.
    1 point
  2. Mhupp Started using the setvars method today on some new code, THANKS. Easier than foreach.
    1 point
  3. @mhupp , this post made me want to study writing lisps, because the syntax and structure of the code is so accessible. I know that writing code is logical, puzzle solving, but seeing it like this just drives that fact home.
    1 point
  4. I should have mentioned CIV3D has something built in if I remember correct. AutoCAD Map 3D Help: Adding a Scale Bar (autodesk.com)
    1 point
  5. If your setting a bunch of values like this. (defun sm-error (msg) (setvar "cmdecho" 0) (if oldattdia (setvar "attdia" oldattdia)) (if oldattreq (command "attreq" oldattreq)) (if oldangbase (setvar "angbase" oldangbase)) (if oldlay (setvar "clayer" oldlay)) (if oldosmode (setvar "osmode" oldosmode)) (princ "Sm Error: ") (setq *error* olderror) (setvar "cmdecho" 1) (princ) ) have this at the start of the main lisp. first two are needed to capture the values. the third line you can set new values all at once but isn't needed. (setq vars '(attdia attreq angbase clayer osmode) ;list of variables vals (mapcar 'getvar vars) ;store old values in a list called vals ) (mapcar 'setvar vars '(# # # "layername" #)) ;set new values So to reset all values back you only need this line. (mapcar 'setvar vars vals) ;sets all values back to before
    1 point
  6. Oh yes, good point. ;; execute command, save with a new name, close drawing (defun autoload ( / new_name) (c:XrefBind) ;; save as. New name: (setq new_name (strcat ;; path (getvar "dwgprefix") ;; dwg name, but cut off the ".dwg" (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4) ) ;; add a postfix (strcat "_bound.dwg") ;; feel free to change this postfix ) ) (command "_saveas" "" new_name) ;;(command "Qsave") (command "close") )
    1 point
  7. Just to note, xrefbind doesn't save the bound drawing as a new drawing, it might be convenient to change the qsave at the end to 'save as' with a file name "Drawing_Number_Bound.Dwg" ?
    1 point
  8. This seems to work fine for binding. To make it even faster you can auto-execute the command. See the end of the script. It executes the command. Autoloads. Closes the drawing. (EDIT: Look at my next reply. You may not want a quick save, rather a save as with a different name) It doesn't ask questions, it just binds everything. (vla-Bind tmpObj :vlax-true) does bind->insert. Perhaps you want false (bind->bind); depending on preferences. ;; slightly modified from: ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-and-bind-all-xrefs-in-modelspace/td-p/3651968 (defun c:XrefBind (/ tmpObj) (vl-load-com) (vlax-for objs (vla-get-ModelSpace (vla-get-activedocument (vlax-get-acad-object)) ) (if (and ;; block insert (= (vla-get-ObjectName objs) "AcDbBlockReference") ;; blocks with a path are xrefs (vlax-property-available-p objs 'Path) ;; make a temporary object (setq tmpObj (vla-Item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)) ) (vla-get-Name objs) ) ) (not (assoc 71 (entget (tblobjname "block" (vla-get-Name objs))))) ) ;; bind xref (progn (vla-Bind tmpObj :vlax-true) ) ) ) (princ) ) ;; execute command, quick save, close drawing (defun autoload ( / ) (c:XrefBind) (command "Qsave") (command "close") ) (autoload) ---- e-transmit, with autoload at the end. It saves a .zip with the same name and in the same folder as the drawing you run it on ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-etransmit-all-open-file/td-p/6063206 (DEFUN c:etra () (command "_qsave") (command "_etransmit" "_c" (strcat (getvar "dwgprefix") (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 3) ) "ZIP" ) ) (command "_close" "Y") ) ;; autoload (c:etra)
    1 point
  9. The formatting looked familiar
    1 point
  10. This seems to be the simpliest way: (defun C:test ( / cmd ) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (foreach Layout (layoutlist) (command "_.-PLOT" "No" ; Detailed plot configuration? [Yes/No] <No>: No Layout ; Enter a layout name or [?] <Layout1>: "" ; Enter a page setup name "DWG To PDF.pc3" ; Enter an output device name or [?] <DWG To PDF.pc3>: (strcat (getvar "DWGPREFIX") Layout ".pdf") ; Directory to save "No" ; save changes to page setup? "Yes" ; proceed with plot? ); command ); foreach (setvar 'cmdecho cmd) (princ) ); defun C:test For the detailed plot configuration check scottbolton's post in this thread.
    1 point
×
×
  • Create New...