
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone !
I am trying to define a block with attributes with LockPosition = On , using DXF codes (280 . 1) and AutoLisp (lisp c: TestPP attached below ) . For Visual Lisp , property LockPosition = Read Only , so can't be changed !
The problem is , this (280 . 1) is having effect only if I introducing codes 100 in blue . But then , I have a problem with TextStyle (7 . "ArialT") .
(defun c:TestPP () (prinC "\n TestPP : V : 1 . 04 . 2019 ;") (setVar "TextStyle" "Standard") (vl-CmdF "_.Purge" "_A" "" "_N") (if (tblSearch "Block" "PxT") (princ "\n Block Existed !") (progn ; Define Block (command "_.Layer" "_N" "Name L" "_C" 1 "Name L" "") ;;; (if (tblSearch "Style" "ArialT") T (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ; ;;; (if (not (tblobjname "Style" "ArialT")) (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ; ;;; (if (not (tblobjname "Style" "ArialT")) (vl-CmdF "-Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ; (if (not (tblSearch "Style" "ArialT")) (vl-CmdF "-Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ; ;;; (cond ( (null (tblSearch "STYLE" "ELEV_ARIAL_1")) ;;; (setq nw_style (vla-Add (vla-get-textStyles (vla-get-ActiveDocument (vlax-get-acad-Object))) "ArialT") ;;; nw_font (strcat (getEnv "systemroot") "\\Fonts\\Arial.ttf") ;;; ) ;end_setq ;;; (mapcar '(lambda (pr val) (vlax-put-Property nw_style pr val)) ;;; (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag) ;;; (list nw_font 0.0 (/ (* 0.0 pi) 180) 1.0 0.0) ;;; ) ;end_mapcar ;;; ) ;;; ) ;end_cond (entMake '((0 . "BLOCK") (2 . "PxT") (70 . 2) (8 . "0") (10 0 0 0) (6 . "ByLayer") (62 . 256) (4 . "Made by Me")) ) ; end of e (entMake (list '(0 . "Circle") '(8 . "0") '(62 . 256) '(6 . "ByLayer") '(10 0 0 0) (cons 40 0.25) ) ) ; end of e (entMake (list '(0 . "AttDef") '(100 . "AcDbEntity") (cons 8 "Name L") '(62 . 256) '(6 . "ByLayer") ;'(67 . 0) '(100 . "AcDbText") '(10 0 0 0) '(40 . 1.5) '(1 . "N") '(50 . 0) '(41 . 1) '(51 . 0) '(7 . "ArialT") '(71 . 0) '(72 . 0) '(11 0.5 +1.0 0) '(210 0.0 0.0 1.0) '(100 . "AcDbAttributeDefinition") '(280 . 0) '(3 . "Point Name") '(2 . "NAME") '(70 . 0) '(73 . 0) '(74 . 2) '(280 . 1) ) ) ; end of e ;'(100 . "AcDbXrecord") (entMake '((0 . "EndBlk") (8 . "0")) ) ; end of e (prinC "\n Block with Attributes DEFINED : PxT ;") ; end of p ) ; else ) ; if (setq ;q (getString "\n Attribute Insertion with Codes 100 : Any = NO ; < Enter = YES > : ") i 0) (repeat 10 ; Inserting 10 Blocks with Attribute (entMake (list '(0 . "Insert") '(2 . "PxT") '(8 . "0") '(66 . 1) (cons 10 (trans (list i i i) 1 0)) '(50 . 0) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0)) ) ; inserare Bloc (if (= (rem i 2) 0) ;(= q "") (entMake (list '(0 . "ATTRIB") '(100 . "AcDbEntity") '(8 . "Name L") '(67 . 0) ;'(6 . "ByLayer") ;'(62 . 256) '(67 . 0) ;0 = MSpace ; '(100 . "AcDbText") (list 10 i i i) '(40 . 1) (cons 1 (ItoA i)) '(50 . 0) '(41 . 1.0) '(51 . 0.0) '(7 . "ArialT") '(71 . 0) '(72 . 0) (cons 11 (trans (list i i i) 1 0)) ;'(210 0.0 0.0 1.0) '(100 . "AcDbAttribute") '(280 . 0) '(2 . "NAME") '(70 . 0) '(73 . 0) (cons 74 2) '(280 . 1) ) ) ; set Attribute (entMake (list '(0 . "ATTRIB") (list 10 i i i) '(8 . "Name L") (cons 1 (ItoA i)) '(280 . 0) '(2 . "NAME") '(40 . 1) '(70 . 0) (cons 11 (trans (list i i i) 1 0)) (cons 72 0) (cons 74 2) '(6 . "ByLayer") '(7 . "ArialT") '(50 . 0) '(62 . 5) '(280 . 1) ) ) ; e ) ; if (entMake '((0 . "SeqEnd") (8 . "0")) ) ; End Insert Block ! (setq i (1+ i)) ) ; r (setVar "TextStyle" "Standard") (command "zoom" "e") (prinC (strCat "\n Inserted : " (ItoA i) " ;")) (prinC "\n TestPP : END ;") (prinC) ) ; defun c:TestPP
I create a condition which is alternating the insertion of the attributes .
Open a new dwg , load and run the lisp . The only difference will be too many grips for blue and odd numbers , because (280 . 1) is not having any effect .
Delete all and run the lisp again . Only the blue and odd attributes are visible .
For a manual insertion , TextStyle for attribute is Standard .
So , at the same time , the same block can have different appearances / properties as : color , height , layer rotation , etc .
If I keep the TextStyle ArialT preserved in the drawing , as current Text Style or used somewhere else , are NO problems .
Any idea ?
Thanks in advance .
Solved! Go to Solution.