Entmake Block Definition Woes

Entmake Block Definition Woes

john.uhden
Mentor Mentor
723 Views
6 Replies
Message 1 of 7

Entmake Block Definition Woes

john.uhden
Mentor
Mentor

What am I doing wrong?  This used to work (in the 90's).
I've added oks to focus on which statement had failed, but it makes it all the way through without succeeding.
Ignore the pipe symbol "|" that prefixes symbol names.  This started in the days when locals weren't local at all, so I had to identify them to set them to nil.

   ;;----------------------------------------------------------------
   ;; This function creates the "SPOT" block definition, and
   ;; the text style "SIMPLEX" used by the block's "ELEV" attribute:
   ;; (09-23-03) changed "ELEV" attribute to layer "0"  and "BYBLOCK"
   ;;            at request of LGA
   ;;            Also changed justification to "ML"
   ;;
   (defun @Anonymous_def ( / |style)
      (if (setq |style (tblsearch "STYLE" "SIMPLEX"))
         (if (or
            (/= (strcase (cdr (assoc 3 |style))) "SIMPLEX")
            (/= (cdr (assoc 40 |style)) 0.0) ; fixed height
            (/= (cdr (assoc 41 |style)) 1.0) ; width factor
            (/= (cdr (assoc 50 |style)) 0.0) ; obliquing angle
            (= (logand (cdr (assoc 70 |style)) 4) 4)   ; flag
            (/= (cdr (assoc 71 |style)) 0))  ; generation flags
            (command "_.style" "SIMPLEX" "simplex" 0.0 1.0 0.0 "_N" "_N" "_N")
         )
         (command "_.style" "SIMPLEX" "simplex" 0.0 1.0 0.0 "_N" "_N" "_N")
      )
(setq ok 99)
      (entmake)
(setq ok 100)
      (entmake
        '((0 . "BLOCK") (2 . "SPOT") (70 . 2) (10 0.0 0.0 0.0))
      )
(setq ok 101)
      (entmake
        '((0 . "TEXT") (8 . "0") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (1 . "+") (40 . 0.0833333333) (50 . 0.785398)(62 . 0)
         (71 . 0) (72 . 4) (73 . 0)) ;; Middle
      )
(setq ok 102)
      (entmake
        '((0 . "ATTDEF") (8 . "0") ;(100 . "AcDbEntity") (100 . "AcDbText")
          (10 0.12 0.0 0.0) (11 0.12 0.0 0.0) ;(100 . "AcDbAttribute")
          (40 . 0.0833333) (1 . "") (3 . "Elev") (2 . "ELEV")
          (73 . 0) (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "SIMPLEX")
          (62 . 0)(71 . 0) (72 . 4) (210 0.0 0.0 1.0) (73 . 0)) ;; Middle, NOT Middle Center
      )
(setq ok 103)
      (entmake '((0 . "ENDBLK")))
   )
 

 

John F. Uhden

0 Likes
Accepted solutions (2)
724 Views
6 Replies
Replies (6)
Message 2 of 7

ronjonp
Mentor
Mentor

I think you're missing some data in the (0 . "BLOCK") and (0 . "ENDBLK") sections. Here's a quick example that creates an attributed block.

 

(defun c:foo nil
  (cond	((null (tblobjname "block" "123"))
	 (entmake '((0 . "BLOCK")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbBlockReference")
		    (66 . 1)
		    (2 . "123")
		    (10 0. 0. 0.)
		    (70 . 2)
		   )
	 )
	 (entmake '((0 . "CIRCLE")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbCircle")
		    (10 0. 0. 0.)
		    (40 . 1.)
		   )
	 )
	 (entmake '((0 . "ATTDEF")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbText")
		    (10 -0.166666666666667 -0.25 0.)
		    (40 . 0.5)
		    (1 . "0")
		    (50 . 0.)
		    (41 . 1.)
		    (51 . 0.)
		    (71 . 0)
		    (72 . 1)
		    (11 0. 0. 0.)
		    (100 . "AcDbAttributeDefinition")
		    (280 . 0)
		    (3 . "123")
		    (2 . "123")
		    (70 . 8)
		    (73 . 0)
		    (74 . 2)
		    (280 . 1)
		   )
	 )
	 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
	)
  )
  (princ)
)

 

You can also entmake your Simplex style 🙂

(entmake '((0 . "STYLE")
	   (100 . "AcDbSymbolTableRecord")
	   (100 . "AcDbTextStyleTableRecord")
	   (2 . "Simplex")
	   (70 . 0)
	   (40 . 0.0)
	   (41 . 1.0)
	   (50 . 0.0)
	   (71 . 0)
	   (42 . 0.125)
	   (3 . "simplex.shx")
	   (4 . "")
	  )
)
0 Likes
Message 3 of 7

CADaSchtroumpf
Advisor
Advisor
Accepted solution

This should work

(defun @Anonymous_DEF ( / )
  (if (not (tblsearch "STYLE" "SIMPLEX"))
    (entmake
      '(
      (0 . "STYLE")
      (100 . "AcDbSymbolTableRecord")
      (100 . "AcDbTextStyleTableRecord")
      (2 . "SIMPLEX")
      (70 . 0)
      (40 . 0.0)
      (41 . 1.0)
      (50 . 0.0)
      (71 . 0)
      (42 . 2.5)
      (3 . "simplex.shx")
      (4 . "")
      )
    )
  )
  (if (not (tblsearch "BLOCK" "SPOT"))
    (progn
      (entmake
        '((0 . "BLOCK") (2 . "SPOT") (70 . 2) (8 . "0") (62 . 256) (6 . "ByLayer") (370 . -2) (10 0.0 0.0 0.0))
      )
      (entmake
        '(
        (0 . "TEXT")
        (100 . "AcDbEntity")
        (67 . 0)
        (410 . "Model")
        (8 . "0")
        (62 . 0)
        (100 . "AcDbText")
        (10 0.0 0.0 0.0)
        (40 . 0.0833333333)
        (1 . "+")
        (50 . 0.785398)
        (41 . 1.0)
        (51 . 0.0)
        (7 . "Arial")
        (71 . 0)
        (72 . 4)
        (11 0.0 0.0 0.0)
        (210 0.0 0.0 1.0)
        (100 . "AcDbText")
        (73 . 0)
        )
      )
      (entmake
        '(
        (0 . "ATTDEF")
        (100 . "AcDbEntity")
        (67 . 0)
        (410 . "Model")
        (8 . "0")
        (62 . 0)
        (100 . "AcDbText")
        (10 0.0 0.0 0.0)
        (40 . 0.0833333)
        (1 . "")
        (50 . 0.0)
        (41 . 1.0)
        (51 . 0.0)
        (7 . "SIMPLEX")
        (71 . 0)
        (72 . 4)
        (11 0.0 0.0 0.0)
        (210 0.0 0.0 1.0)
        (100 . "AcDbAttributeDefinition")
        (280 . 0)
        (3 . "Elev")
        (2 . "ELEV")
        (70 . 0)
        (73 . 0)
        (74 . 0)
        (280 . 1)
        )
      )
      (entmake '((0 . "ENDBLK") (8 . "0") (62 . 256) (6 . "ByLayer") (370 . -2)))
    )
  )
)
0 Likes
Message 4 of 7

ronjonp
Mentor
Mentor
Accepted solution

@CADaSchtroumpf and @john.uhden 

I personally don't entmake blocks with attributes. I've found they can be a bit wonky. Even the examples above look correct but when you open them in the block editor the attribute is invisible .. until you close and reopen the drawing. Also sometimes the font they were created with does not stick.

0 Likes
Message 5 of 7

john.uhden
Mentor
Mentor

@ronjonp and @CADaSchtroumpf ,

I guess that the 100 codes are required these days, where they weren't 30 years ago.

I'll try out the additions.

Meanwhile I made the block definition manually so I could move along.

Thanks, guys.

John F. Uhden

0 Likes
Message 6 of 7

charmingladyfool
Contributor
Contributor

Please check line number 22. You put (entmake)  without any list

0 Likes
Message 7 of 7

john.uhden
Mentor
Mentor

@charmingladyfool 

You are no fool.  Thanks for pointing that out.

I put the naked entmake in there for a purpose...

It stops any previous entmake that may have been under construction.

I'd sure be surprised to have created an attribute attached to a polyline or some other kind of morph.

John F. Uhden

0 Likes