Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/07/2019 in all areas

  1. We'll make a geek out of you yet , you nerd haha happy coding
    1 point
  2. I posted this before but you can use find replace to edit scripts adding like rlx code, I normally just start with a dwg names text file. This is created using old fashioned DOS commands dir *.dwg >dwglst.txt Using Word you can change end of line or start of line adding stuff like open, close y it’s ^p for end of line.
    1 point
  3. you have to either load the lisp file every time in the script file (as in example line above my code) or you must make sure this file is auto-loaded every time you open a file , for example with s::startup in your acad.lsp or just add it as a standard routine in your acad.lsp. With a few mod's code can be added to my first code which uses odbx but scripts are more fun to look at even though they are a little bit slower.
    1 point
  4. a quicky before breakfast ;;; Attach Xref to all drawings in Folder , RLX 6-Feb-2019 (defun c:RlxFaXref (/ _getfolder app adoc odbs odbx v xref folder dwg xr) (vl-load-com) (defun _getfolder ( m / sh f r ) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application") f (vlax-invoke-method sh 'browseforfolder 0 m 0)) (vlax-release-object sh)(if f (progn (setq r (vlax-get-property (vlax-get-property f 'self) 'path))(if (wcmatch r "*\\") r (strcat r "\\"))))) ; i is 0 (absolute), 1 (relative) of 2 (no) -xref path (defun RLXref_SetPathType (i) (vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\XattachDialog") "PathType" i)) (setq odbs "ObjectDBX.AxDbDocument" v (substr (getvar 'acadver) 1 2) adoc (vla-get-activedocument (setq app (vlax-get-acad-object)))) (RLXref_SetPathType 1) (cond ((vl-catch-all-error-p (setq odbx (vl-catch-all-apply 'vla-getinterfaceobject (list app (if (< (atoi v) 16) odbs (strcat odbs "." v)))))) (princ "\nObject DBX interface not created!")) ((not (setq xref (getfiled "Select Xref to attach" "" "dwg" 0))) (alert "No Xref was selected")) ((setq folder (_getfolder "Select folder with drawings to attach xref to")) (foreach dwg (vl-directory-files folder "*.dwg" 0) (setq dwg (strcat folder dwg)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx dwg))) (princ (strcase (strcat "\nError opening: " dwg))) (progn (princ (strcat "\nOpening: " dwg)) ; attach xref (if (vl-catch-all-error-p (setq xr (vl-catch-all-apply 'vla-AttachExternalReference (list (vla-get-ModelSpace odbx) xref (vl-filename-base xref) (vlax-3d-point 0 0 0) 1 1 1 0 :vlax-false)))) (princ (vl-catch-all-error-message xr))) ; save drawing (vla-saveas odbx (vla-get-name odbx)) ) ) ) ) ) (princ) )
    1 point
  5. (defun c:t1 ( / ss i fol e lst ip p1 p2 txt) (if (setq ss (ssget "x" '((0 . "TEXT")))) (repeat (setq i (sslength ss)) (if (wcmatch (cdr (assoc 1 (entget (setq e (ssname ss (setq i (1- i))))))) "@#,@##,@###") (setq lst (cons e lst))))) (if lst (progn (princ "\nWorking.....") (setvar 'filedia 0) (setq fol (getvar 'dwgprefix)) (foreach e lst (setq ip (cdr (assoc 11 (entget e))) txt (cdr (assoc 1 (entget e))) p1 (list (+ (car ip) -0.75) (+ (cadr ip) 0.75)) p2 (list (+ (car ip) 15.22) (+ (cadr ip) -0.75))) (vl-cmdf "._zoom" "w" p1 p2 "jpgout" (strcat fol txt) "w" p1 p2 "") ) ) ) (setvar 'filedia 1) (princ) )
    1 point
  6. Hi! Use (setq total-nabor (ssget)) instead of (setq total-nabor (ssget "x" '((410 . "model")))) ssget without arguments will prompt the user to select objects through the AutoCAD general 'Select objects:' mechanism.
    1 point
  7. No, not necessary.. I'd even say that it is best if the lisp makes the job directly on automatically generated files. If there is no man made manipulation before, the input is constant... Au contraire! It is easier to discard any overrides that contain "" than trying to manipulate the string to compare it to a real number. Ok, here it is. At the beginning, there is the variable exclusionlist. I made the lisp to disregard any item in it, so for now it wont modify any dimensions with no overrides ("") and wont modify "" overrides. Any other dimension will get overlined. Since the dimensions that have same override as original value have I didn't bother comparing overwrittenvalue and realvalue. No need to do so. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;LSP routine made by Jef! ;;2014-02-06 ;;with no expressed written or applied warranty ;;;;;;;;;;;;;; (defun c:OverrideFinder ( / working_list counter entity entityslist overwrittenvalue realvalue exclusionlist) (command "undo" "be") (setq exclusionlist (list "<>" ""));add more if required (if (setq working_list (ssget "_X" '((0 . "*DIMENSION")) )) (progn (princ "Dimensions detected") (setq counter 0) (while (< counter (sslength working_list)) (setq entity (ssname working_list counter)) (setq entityslist (entget entity)) (if (not (member (setq overwrittenvalue (cdr (assoc 1 entityslist))) exclusionlist)) (progn (princ "\nDimension processed!") (setq realvalue (cdr (assoc 42 entityslist))) (entmod (subst (cons 1 (strcat "%%o" overwrittenvalue)) (assoc 1 entityslist) entityslist)) );progn (princ "\nDimension with no overwride skipped") );if (setq counter (+ 1 counter)) );while );progn (alert "No dimensions found.. Ungroup first!") ) (princ "Processing finished") (command "undo" "end") ) Pretty nifty, huh? If you want to learn LISP, analyze everything expression by expression.. With dedication it is possible to achieve many things. I never took any class and my post-its made 3 or 4 months ago look like "structure of the if function", "setq doesn't need quotation marks, setvar does".. and look at what I just made. Actually, I self impressed myself! don't hesitate to Google any function to fully understand it. Take many written notes, it helps assimilate knowledge.. And every time you review your notes you can see the progress you made. For instance: "Hey, last month I needed my notes to make a cond statement". Don't hesitate to ask if further explanations are required. (you should) Happy coding, Cheers Jef!
    1 point
×
×
  • Create New...