TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on July 19, 2010, 03:37:04 AM

Title: What is diffirence between BLOCK and INSERT?
Post by: HasanCAD on July 19, 2010, 03:37:04 AM
What is difference between a block definition (BLOCK) and block references (INSERT)?

Code: [Select]
(defun HM:add_Coordblock ()
  (if (not (tblsearch "block" "EC-CoordPoint"))
    (progn
      (entmake (list (cons 0 "BLOCK")
(cons 100 "AcDbEntity")
(cons 67 0)
(cons 8 "0")
(cons 100 "AcDbBlockReference")
(cons 2 "EC-CoordPoint")
(cons 10 (nth (+ 5 n) XlsLst) (nth (+ 6 n) XlsLst) (nth (+ 7 n) XlsLst)) ;base point
(cons 70 0)
)
       )

      (entmake (list (cons 0 "POINT")
(cons 100 "AcDbEntity")
         (cons 67 0)
         (cons 8 "0")
         (cons 100 "AcDbPoint")
         (cons 10 0.0 0.0 0.0)
         (cons 50 0.0)
)
       )

      (entmake (list (0 "ATTDEF")
         (cons 100 "AcDbEntity")
         (cons 67 0)
         (cons 8 "0")
         (cons 100 "AcDbText")
         (cons 10 -1433.142857142857 -110.0 0.0)
         (cons 40 220.0)
         (cons 1 (nth (+ 4 n) XlsLst)) ;Vlaue
         (cons 50 0.0)
         (cons 41 0.8)
         (cons 51 0.0)
         (cons 7 "EC-22-100")
         (cons 71 0)
         (cons 72 1)
         (cons 11 0.0 0.0 0.0)
         (cons 100 "AcDbAttributeDefinition")
         (cons 3 "EC-CoordPoint_PROMPT")
         (cons 2 "EC-COORDPOINT_TAG")
         (cons 70 0)
         (cons 73 0)
         (cons 74 2)
         (cons 280 0)
)
       )

      (entmake (list (cons 0 "ENDBLK")
(cons 100 "AcDbBlockEnd")
(cons 8 "0")
)
       )
      )
    )

  (princ)
  )


Thanks
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: Kerry on July 19, 2010, 03:46:54 AM

Haven't tried your code, but a couple of questions ..

What do you think the code does ?

What is the value of n ?

What is the value of XlsLst ?

Title: Re: What is diffirence between BLOCK and INSERT?
Post by: HasanCAD on July 19, 2010, 04:37:21 AM
I am tring to import a data from xls file using Gile tool Excel read and write (http://www.theswamp.org/index.php?topic=31441.0)

The full idea is
- Import points coordenate from excel file
- Then process these points in AutoCAD (move and rotate) to match the master plan
- Then export the new data to an excel sheet again.

What I am thinking is creating a block with insertion point and an attribute with point number to be able to export to the excel sheet with the points sequance

Attached a snapshot for the excel sheet

Code: [Select]
(defun c:CoordBlock ()
  (vl-load-com)

    (setq time (getvar "millisecs")
  n -1
  XlsLst (gc-xlread "C:/EC-Menu/Help/EC-Coordinates.xls" "Coord")
  )

  (while
    (HM:add_Coordblock)
    (setq n (1+ n))
    )
   
(defun HM:add_Coordblock ()
  (if (not (tblsearch "block" "EC-CoordPoint"))
    (progn
      (entmake (list (cons 0 "BLOCK")
(cons 100 "AcDbEntity")
(cons 67 0)
(cons 8 "0")
(cons 100 "AcDbBlockReference")
(cons 2 "EC-CoordPoint")
(cons 10 (nth (+ 5 n) XlsLst) (nth (+ 6 n) XlsLst) (nth (+ 7 n) XlsLst)) ;base point
(cons 70 0)
)
       )

      (entmake (list (cons 0 "POINT")
(cons 100 "AcDbEntity")
         (cons 67 0)
         (cons 8 "0")
         (cons 100 "AcDbPoint")
         (cons 10 0.0 0.0 0.0)
         (cons 50 0.0)
)
       )

      (entmake (list (0 "ATTDEF")
         (cons 100 "AcDbEntity")
         (cons 67 0)
         (cons 8 "0")
         (cons 100 "AcDbText")
         (cons 10 -1433.142857142857 -110.0 0.0)
         (cons 40 220.0)
         (cons 1 (nth (+ 4 n) XlsLst)) ;Vlaue
         (cons 50 0.0)
         (cons 41 0.8)
         (cons 51 0.0)
         (cons 7 "EC-22-100")
         (cons 71 0)
         (cons 72 1)
         (cons 11 0.0 0.0 0.0)
         (cons 100 "AcDbAttributeDefinition")
         (cons 3 "EC-CoordPoint_PROMPT")
         (cons 2 "EC-COORDPOINT_TAG")
         (cons 70 0)
         (cons 73 0)
         (cons 74 2)
         (cons 280 0)
)
       )

      (entmake (list (cons 0 "ENDBLK")
(cons 100 "AcDbBlockEnd")
(cons 8 "0")
)
       )
      )
    )

  (princ)
  )
  (princ (strcat "\n<< Time took: " (rtos (/ (- (getvar "millisecs") time) 1000.) 2 4) " secs. >>"))
  )

Title: Re: What is diffirence between BLOCK and INSERT?
Post by: Tharwat on July 19, 2010, 06:38:16 AM

Well, BLOCK is made of gathered entities to be used later on as one object in a drawing of Autocad.  :ugly:
So the INSERT is the mechanical process to get your BLOCK come true in reality.. is that clear  :pissed:
 :-D  :-D  :-D

Tharwat
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: Kerry on July 19, 2010, 06:42:35 AM
Quote
What do you think the code does ?
has not been resolved.

To deal with block definition and inserts using entmake :

FIRST :
If the BLOCK definition is not in the Block Table
then create the BLOCK

Then SECOND :
  To create the INSERT



When you can do that you can start to consider automating the process
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: Lee Mac on July 19, 2010, 02:16:19 PM
Perhaps read this (http://www.theswamp.org/index.php?topic=31200.0) thread also.
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: Kerry on July 20, 2010, 05:31:11 AM
Quote

Hello.
Is there anybody in there?
Just nod if you can hear me.
Is there anyone home?


Title: Re: What is diffirence between BLOCK and INSERT?
Post by: ElpanovEvgeniy on July 20, 2010, 05:39:39 AM
Quote

Hello.
Is there anybody in there?
Just nod if you can hear me.
Is there anyone home?



Hi!  :-)
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: HasanCAD on July 20, 2010, 07:41:01 AM
Quote

Hello.
Is there anybody in there?
Just nod if you can hear me.
Is there anyone home?




Hi Kerry
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: dgorsman on July 20, 2010, 11:19:09 AM
The difference between a BLOCK and an INSERT (more correctly, a block reference) is the difference between a blueprint and the actual building.
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: Hangman on July 20, 2010, 03:00:57 PM
The difference between a BLOCK and an INSERT (more correctly, a block reference) is the difference between a blueprint and the actual building.

So, ... your saying that ... a BLOCK is to a Building what an INSERT is to a blueprint ??<Sarc>   :-D

(grrrr, ... stupid sarc marks ain't work'n)   :realmad:
Title: Re: What is diffirence between BLOCK and INSERT?
Post by: dgorsman on July 20, 2010, 03:31:46 PM
Other way 'round - the BLOCK is the blueprint, which provides the instructions to build the actual object; in this case, a block reference.  Many buildings can be built off of the same blueprint, but they can (and usually do) vary slightly depending on who put them on site.