Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/03/2023 in all areas

  1. Just use (if(ade_projgetwscode) for the test. In AutoCAD it returns "; error: no function definition: ADE_PROJGETWSCODE" since only a Map vertical can have a Map Projection set, even if one isn't set in Map it will return "".
    1 point
  2. I've had this one in the toolbox for a while: (defun c:layerprefix (/ e el l f s tm) ;; RJP - 04.03.2018 (or (setq f (getenv "RJP_LayerPrefix")) (setq f (getenv "username"))) (if (and (setq f (cond ((/= "" (setq tm (getstring (strcat "\nEnter prefix [<" f ">]: ")))) tm) (f) ) ) (setq s (ssget ":L" (list (cons 8 (strcat "~" f "*"))))) ) (progn (setenv "RJP_LayerPrefix" f) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq l (cdr (assoc 8 (entget e)))) (setq el (entget (tblobjname "layer" l))) (if (not (tblobjname "layer" (strcat f l))) (entmakex (subst (cons 2 (strcat f l)) (assoc 2 el) el)) ) (entmod (subst (cons 8 (strcat f l)) (assoc 8 (entget e)) (entget e))) ) ) ) (princ) )
    1 point
  3. 1. This is the correct syntax (ssget "x" (list (cons 0 "insert")(cons 2 "Titleblock_Properties_22x34"))) 2. You need to iterate thru the selection set via index number 3. _AttFunc purpose is to use one function for both GET and SET Here's an example of the functions usage If your purpose is to set the value of the sheet as per layout tab name (defun c:demo ( / ss totalLayout ent layname) (if (setq ss (ssget "x" '((0 . "INSERT")(2 . "Titleblock_Properties_22x34")))) (progn (setq totalLayout (itoa (length (layoutlist)))) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) layname (cdr (assoc 410 (entget ent)))) (_AttFunc ent (mapcar 'list '("LTSHTDESC" "LTSHTNUM") (list (strcat layname " OF " totalLayout) layname))) ) ) ); if (princ) ) Let me know what in mind so we can complete the code, perhaps we can use fields value for both TAGS
    1 point
  4. FYI when you need to set multiple variables (setq vars '(osmode snapang orthomode cmdecho) ;list of variables vals (mapcar 'getvar vars) ;store current values for restore in a list called 'vals ) (mapcar 'setvar vars '(0 0 1 0)) ;set new values setting osmode=0 snapang=0 orthomode=1 cmdecho=0 ;use this before you acually set the snapang so 0 is overwritten (mapcar 'setvar vars vals) ;restore old values
    1 point
  5. Okay, let's start here. Command CTA (for Change Titleblock Attributes) to start the function This selects the the title block on the current Layout, then asks the user to fill in LTSHTDESC and LTSHTNUM. ;; Load Visual Lisp (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Lee Mac, read and set attributes: ;; @see http://www.lee-mac.com/attributefunctions.html ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun LM:vl-getattributevalue ( blk tag ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) ;; Get Attribute Values - Lee Mac ;; Returns an association list of attributes present in the supplied block. ;; blk - [ent] Block (Insert) Entity Name ;; Returns: [lst] Association list of ((<tag> . <value>) ... ) ;; http://www.lee-mac.com/attributefunctions.html#algetattributevaluerc (defun LM:getattributevalues ( blk / enx ) (if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))) (cons (cons (cdr (assoc 2 enx)) (cdr (assoc 1 (reverse enx))) ) (LM:getattributevalues blk) ) ) ) ;; Set Attribute Value - Lee Mac ;; Sets the value of the first attribute with the given tag found within the block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; val - [str] Attribute Value ;; Returns: [str] Attribute value if successful, else nil. (defun LM:vl-setattributevalue ( blk tag val ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (progn (vla-put-textstring att val) val) ) ) (vlax-invoke blk 'getattributes) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun cgange_titleblock ( / ss blk) ;; select the title block on current layout. ;; (getvar "ctab") returns the current layout. The block keeps this information in: (assoc 410 blk) (setq ss (ssget "_X" (list (cons 0 "insert") (cons 2 "Titleblock_Properties_22x34") (cons 410 (getvar "ctab")) )) ) (setq blk (ssname ss 0)) ;; ;;(LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTDESC" "Detail 1 - Detail 15") (LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTDESC" (getstring "\nLTSHTDESC: " T)) ;;(LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTNUM" "D-1") (LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTNUM" (getstring "\nLTSHTNUM: " T)) ) ;; Type command CTA (for Change Titleblock Attributes) to start the function (defun c:cta ( / ) (cgange_titleblock) (princ) ) What more would you like the function to do? More can be automated of course. For example, we could make a list (list (list "Sheet1" "Detail 1 - Detail 15" "D-1") (list "Sheet1" "Detail 2 - Detail 15" "D-2") (list "Sheet1" "Detail 3 - Detail 15" "D-3") ;; ... ) ... then the function fills in everything ...
    1 point
×
×
  • Create New...