Author Topic: Creating an INSERT?  (Read 2972 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Creating an INSERT?
« on: January 20, 2005, 10:52:33 PM »
I just can't seem to create this insert.
Where did i go wrong?
What is the minimum data needed to create an insert?

Code: [Select]
(defun makearrow (blockname)

  (entmake
    (list '(0 . "INSERT")
          ;'(100 . "AcDbEntity")
          '(100 . "AcDbBlockReference")
          '(8 . "0")
          ;'(66 . 0)
          (cons 2 blockname)
          '(10 0.0 0.0 0.0)
          '(41 . 1.0)
          '(42 . 1.0)
          '(43 . 1.0)
          '(50 . 0.0)
          ;'(210 0.0 0.0 1.0)
    ) ;list
  ) ;entmake

  (entmake '((0 . "SOLID") (8 . "0")
             (10 66.0 -1.42109e-014 0.0)
             (11 52.8688 -2.32308 0.0)
             (12 52.8688 2.32308 0.0)
             (13 52.8688 2.32308 0.0)
             (39 . 0.0)
            )
  )
  (entmake '((0 . "LINE") (8 . "0") (10 0.0 0.0 0.0) (11 66.0 -1.42109e-014 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 29.1563 -16.9136 0.0) (11 33.0 -7.10543e-015 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 23.8848 16.2547 0.0) (11 29.1563 -16.9136 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 16.6366 -8.7863 0.0) (11 23.8848 16.2547 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 12.1311 8.7863 0.0) (11 16.6366 -8.7863 0.0)))
  (entmake (list '(0 . "SEQEND") '(100 . "AcDbEntity") '(8 . "0")))
)

(defun c:test ()
  (makearrow "darrow")
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CarlB

  • Guest
Creating an INSERT?
« Reply #1 on: January 21, 2005, 01:40:52 AM »
I've only dabbled in this but...
I think you need to first entmake a "block", then entmake an "insert". So if I'm right, change "insert" to "block" and "seqend" to "endblock".  You may not (should not?) need the group code 100's.  This should create the block definition.  Then entmake the "insert" - should just need insertion point, rotation, block name, scale, layer (optional?).

SMadsen

  • Guest
Creating an INSERT?
« Reply #2 on: January 21, 2005, 06:17:35 AM »
CAB, are you sure you posted the right code? Where' the ATTDEF's??

As CarlB says, the code 100's are not needed for block definitions (but nice to include, I think).

Here's something to start with (line art left out):
Code: [Select]
(defun makearrow (blockname)
  ;;  Block with attributes
  ;; .. (if (tblsearch "BLOCK" blockname) .. then ask for redef? .. etc ..
  (entmake
    (list '(0 . "BLOCK")
          '(100 . "AcDbEntity")
          '(100 . "AcDbBlockBegin")
          ;; ^ code 100's not needed for BlockBegin but nice to have
          ;; for future reference
          (cons 2 blockname)
          '(70 . 0)
          '(10 0.0 0.0 0.0)
    ) ;_ list
  ) ;_ entmake

  ;; ... ETC....

  (entmake
    (list '(0 . "ENDBLK") '(100 . "AcDbBlockEnd"))
    ;; ^code 100 for BlockEnd not needed either but still good
    ;; to have for reference
  )
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Creating an INSERT?
« Reply #3 on: January 21, 2005, 08:36:44 AM »
Well I think I may have the wrong idea about blocks.
Perhaps someone should splane it to me one more time.
I thought that an 'Insert' was the master definition of the block and existed
in the definition table only, not in the drawing.
Then a 'Block' was the actual object in the drawing and there may be many of
these with different scales, rotations & insertion points.

If the 'Block' had attributes then the attribute definition existed in the
'Insert' only and the actual attribute data exist in each 'Block'

I thought that the 'Insert' would exist with or without attributes as the definition
of that block and the 'Block' was a copy that held the data pertinent to that
individual blocks location.


So straighten me out please.

PS I inadvertently left the comment in the code posted, sorry
;; block with attributes
should have been removed, it is now.

As usual i was cutting & pasting code snippets. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Creating an INSERT?
« Reply #4 on: January 21, 2005, 09:19:30 AM »
Ok this is what I got from your example:

Code: [Select]
;;  Example of a Entmake of a Block
;;
(defun makearrow (blockname)
  ;;==============================================
  ;;       Start of Block definition              
  ;;==============================================
  (entmake
    (list '(0 . "BLOCK")            ; required
          '(100 . "AcDbEntity")     ; recommended
          '(100 . "AcDbBlockBegin") ; recommended
          (cons 2 blockname)        ; required
          '(8 . "0")                ; recommended
          '(70 . 0)                 ; required
          '(10 0.0 0.0 0.0)         ; required
    )
  )
  ;;==============================================

 
  ;;==============================================
  ;;            Block objects                    
  ;;==============================================
  (entmake '((0 . "SOLID") (8 . "0")
             (10 66.0 -1.42109e-014 0.0)
             (11 52.8688 -2.32308 0.0)
             (12 52.8688 2.32308 0.0)
             (13 52.8688 2.32308 0.0)
             (39 . 0.0)
            )
  )
  (entmake '((0 . "LINE") (8 . "0") (10 0.0 0.0 0.0) (11 66.0 -1.42109e-014 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 29.1563 -16.9136 0.0) (11 33.0 -7.10543e-015 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 23.8848 16.2547 0.0) (11 29.1563 -16.9136 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 16.6366 -8.7863 0.0) (11 23.8848 16.2547 0.0)))
  (entmake '((0 . "LINE") (8 . "0") (10 12.1311 8.7863 0.0) (11 16.6366 -8.7863 0.0)))
  ;;==============================================
 

  ;;==============================================
  ;;     This is the end of block marker          
  ;;==============================================
  (entmake (list '(0 . "ENDBLK")         ; required
                 '(100 . "AcDbBlockEnd") ; recommended
                 '(8 . "0")              ; recommended
                 ))
  ;;==============================================
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

SMadsen

  • Guest
Creating an INSERT?
« Reply #5 on: January 21, 2005, 09:26:10 AM »
Quote from: CAB
Well I think I may have the wrong idea about blocks.

Yep, you've got it the other way 'round :)

A regular block that is inserted into the drawing consists of three parts: the BLOCK_RECORD, the BLOCK definition and the INSERT. In that order. Although you get the block definition when accessing the block symbol table, it is actually the block record that is located within the symbol tables (block def's have no references to the symbol table except via the block records).

In a simplied manner, I guess the hierarchy would go like this:
Code: [Select]

BLOCK_RECORD
  |
{BLOCK
   [- line art]
   [- attdefs]
ENDBLK}
  |
{INSERT
   [- attributes
SEQEND]}


where only the INSERT is a graphical entity. Attdef's exist within the block definition and attributes within the inserted block, the INSERT.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Creating an INSERT?
« Reply #6 on: January 21, 2005, 10:37:15 AM »
Well I sometimes think 'Backwards' is my middle name. :)

Thanks Stig.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.