TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on July 19, 2010, 03:37:04 AM
-
What is difference between a block definition (BLOCK) and block references (INSERT)?
(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
-
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 ?
-
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
(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. >>"))
)
-
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
-
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
- 1. Entmake the BLOCK entity.
- 2. Entmake one ATTDEF entity for each attribute.
- 3. Entmake a ENDBLK entity.
Then SECOND :
To create the INSERT
- 1. Entmake the INSERT entity.
- 2. Entmake one ATTRIB entity for each attribute.
- 3. Entmake a SEQEND entity.
When you can do that you can start to consider automating the process
-
Perhaps read this (http://www.theswamp.org/index.php?topic=31200.0) thread also.
-
Hello.
Is there anybody in there?
Just nod if you can hear me.
Is there anyone home?
-
Hello.
Is there anybody in there?
Just nod if you can hear me.
Is there anyone home?
Hi! :-)
-
Hello.
Is there anybody in there?
Just nod if you can hear me.
Is there anyone home?
Hi Kerry
-
The difference between a BLOCK and an INSERT (more correctly, a block reference) is the difference between a blueprint and the actual building.
-
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:
-
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.