Results 1 to 3 of 3

Thread: Define and insert blocks with attributes , using DXF codes and lisp

  1. #1
    Member
    Join Date
    2011-07
    Posts
    3
    Login to Give a bone
    0

    Default Define and insert blocks with attributes , using DXF codes and lisp

    Hello everyone!

    I am struggling to find the problem in the below lisp file :

    Code:
    
    
    Code:
    (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
     ;  (setVar "TextStyle" "Standard")
     ;  (vl-CmdF "_.Purge" "_A" "" "_N")
       (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") ) ;
    
       (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 "0 Name") '(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 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
    
      (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)
                           (cons 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 . "DENUMIRE") '(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 . 256) '(280 . 1) )  ) ; e
    
    
    
      (entMake '((0 . "SeqEnd") (8 . "0")) ) ; End Insert Block !
    
      (setq i (1+ i))  
     ) ; r
    
     (prinC (strCat "\n   Inserted  :  " (ItoA i) "  ;"))
     (prinC "\n   TestPP  :  END  ;") (prinC)
    ) ; defun


    1 . So , open a new Autocad file , load and run the program .

    2 . delete everything and run the code again .

    The attributes are not visible .

    What is the problem ? Text Style or Insertion of Attribute definition ?

    If I remove all the dxf codes 100 , the TextStyle is working fine , but the dxf codes 280 for LockPosition , is not working .


    Thanks in advance !




    Attached Images Attached Images

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,093
    Login to Give a bone
    0

    Default Re: Define and insert blocks with attributes , using DXF codes and lisp

    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  3. #3
    Member
    Join Date
    2011-07
    Posts
    3
    Login to Give a bone
    0

    Default Re: Define and insert blocks with attributes , using DXF codes and lisp

    Yes it is my post . I still look for an answer .

    Code:
    (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
    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 . The red ones are not visible . Why ?

    Thanks in advance .




Similar Threads

  1. Replies: 0
    Last Post: 2014-05-24, 03:39 AM
  2. Reading DXF codes in VBA
    By IanR in forum VBA/COM Interop
    Replies: 3
    Last Post: 2006-05-25, 02:08 PM
  3. dxf codes for INSERT
    By madcadder in forum AutoLISP
    Replies: 3
    Last Post: 2005-06-27, 07:21 AM
  4. Layout dxf codes
    By wildtb in forum AutoLISP
    Replies: 2
    Last Post: 2004-09-02, 09:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •