Jump to content

Leaderboard

Popular Content

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

  1. I'm guessing your ANGBASE is non-zero - change: obl (* pi (/ 75.0 180.0)) To: obl (* pi (/ 15.0 180.0))
    1 point
  2. I don't have much experience working with Annotative objects, but the following should perform as required: (defun c:a ( / ang cmd ent hgt ins obj obl ocs sty txt ) (setq sty (if (tblsearch "style" "L80") "L80" (getvar 'textstyle)) hgt (getvar 'textsize) obl (* pi (/ 75.0 180.0)) ocs (trans '(0 0 1) 1 0 t) ang (angle '(0 0) (trans (getvar 'ucsxdir) 0 ocs t)) ) (while (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect an object with area: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (vlax-property-available-p (setq obj (vlax-ename->vla-object ent)) 'area)) (princ "\nThe selected object has no area property.") ) ( (setq ins (getpoint "\nSpecify text insertion point: ")) (setq txt (entmakex (list '(000 . "TEXT") '(008 . "leg-area") (cons 007 sty) (cons 040 hgt) (cons 001 (artos (vla-get-area obj))) (cons 050 ang) (cons 051 obl) (cons 010 (trans ins 1 ocs)) (cons 210 ocs) ) ) ) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (vl-cmdf "_.chprop" txt "" "_A" "_Y" "") (setvar 'cmdecho cmd) ) ) ) ) (princ) ) (defun artos ( a ) (if (< a 1000) (strcat (rtos a 2 1) " m%%253") (strcat (rtos (* a 1e-4) 2 1) " ha") ) ) (vl-load-com) (princ)
    1 point
  3. The less than 10 is pretty common this is another simple example of padding. Rlx nice idea "\t" (if (< (car dwgnum) 10.0) (setq newstr2 (strcat dwgname "-D0" (rtos sheetnum 2 0))) (setq newstr2 (strcat dwgname "-D" (rtos sheetnum 2 0))) )
    1 point
  4. you're welcome. Note that Bigal's suggestion to use tabs ("\t") is working too for the x/y/z part of your table if all number are roughly the same length , so you would only need to right align your counter and the rest could be done with tabs. Doubt in real life you would be able to measure the difference in speed but theoretically tabs should be a little faster.
    1 point
  5. Other way than \t could be (defun write_example (/ pt lst fl_name count l) (while (setq pt (getpoint "\nClik ->>")) (setq lst (cons pt lst))) (if (and lst (setq fl_name (acet-ui-getfile "--< Save as... >--" (getvar "DWGPREFIX") "txt" "" 1))) (progn (setq count 1 l 15 fl (open fl_name "w")) (write-line (strcat (fus "No" l)(fus "X" l)(fus "Y" l)(fus "Z" l)) fl) (foreach itm lst (write-line (strcat (fus (itoa count) l) (fus (rtos (car itm)) l) (fus (rtos (cadr itm)) l) (fus (rtos (caddr itm)) l)) fl) (setq count (+ count 1)) ) (close fl) ) ) (princ) ) ; fill up string (defun fus (s i) (while (> i (strlen s))(setq s (strcat s " "))) s)
    1 point
  6. Try using say tabs (strcat "x" (chr xx) "y" (chr xx) etc I will have to look up what a tab is. need my ascii table. found it 9 (chr 9)
    1 point
  7. Here are a couple of existing programs: Match Dynamic Block Properties Match Attribute Values & Visibility State
    1 point
  8. Yes. The functions to deal with dynamic props can be found here: http://www.lee-mac.com/dynamicblockfunctions.html I wrote a little command MV for Match Visibility (bottom function) (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GET ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Dynamic Block Property Allowed Values - Lee Mac ;; Returns the allowed values for a specific Dynamic Block property. ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; Returns: [lst] List of allowed values for property, else nil if no restrictions (defun LM:getdynpropallowedvalues ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername ( blk / vis ) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda ( pair ) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair))))) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) ;; Get Dynamic Block Visibility State - Lee Mac ;; Returns the value of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Value of Visibility Parameter, else nil (defun LM:getvisibilitystate ( blk / vis ) (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SET ;; Set Dynamic Block Visibility State - Lee Mac ;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed) ;; blk - [vla] VLA Dynamic Block Reference object ;; val - [str] Visibility State Parameter value ;; Returns: [str] New value of Visibility Parameter, else nil (defun LM:SetVisibilityState ( blk val / vis ) (if (and (setq vis (LM:getvisibilityparametername blk)) (member (strcase val) (mapcar 'strcase (LM:getdynpropallowedvalues blk vis))) ) (LM:setdynpropvalue blk vis val) ) ) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Match (Dynamic Prop) Visibility ;; MV for Match Visibility (defun c:mv ( / sourceblock val ss i obj) ;; select source block and read its visibility state value (setq sourceblock (vlax-ename->vla-object (car (entsel "\nSelect Source Block: ")))) (setq val (LM:getvisibilitystate sourceblock)) ;; select destination blocks (princ "\nSelect Destination Blocks, then press Enter: ") (setq ss (ssget (list '(0 . "INSERT") ))) (setq i 0) (repeat (sslength ss) (setq obj (vlax-ename->vla-object (ssname ss i))) (LM:SetVisibilityState obj val) (setq i (+ i 1)) ) (princ) )
    1 point
×
×
  • Create New...