View Full Version : Retrieve XDATA '("ACAD")
e.wijbrandts
2008-11-17, 03:50 PM
Hi all,
I'm trying to retrieve XDATA from blocks I use, especially the insertion units.
In comparison to VBA's ActiveDocument.Blocks.Item("MyBlockName").Units I would like to be able to do this with VLisp.
I am already familiar with (entget ent '("ACAD")), but this doesn't do the trick.
BTW I'm not even sure that this setting is embedded in XDATA or maybe somewhere else.
plz help
thanx in advance
E. Wijbrandts
hofcad
2008-11-17, 06:10 PM
Hi all,
I'm trying to retrieve XDATA from blocks I use, especially the insertion units.
In comparison to VBA's ActiveDocument.Blocks.Item("MyBlockName").Units I would like to be able to do this with VLisp.
I am already familiar with (entget ent '("ACAD")), but this doesn't do the trick.
BTW I'm not even sure that this setting is embedded in XDATA or maybe somewhere else.
plz help
thanx in advance
E. Wijbrandts
(setq ent (entsel))
(vlax-dump-object (vlax-Ename->Vla-Object (car ent)) T)
(setq ent (entsel))
(vlax-get-property (vlax-Ename->Vla-Object (car ent)) 'InsUnits)
(setq ent (entsel))
(vla-get-insunits (vlax-Ename->Vla-Object (car ent)))
Regards, HofCAD CSI.
e.wijbrandts
2008-11-17, 10:46 PM
(setq ent (entsel))
(vlax-dump-object (vlax-Ename->Vla-Object (car ent)) T)
(setq ent (entsel))
(vlax-get-property (vlax-Ename->Vla-Object (car ent)) 'InsUnits)
(setq ent (entsel))
(vla-get-insunits (vlax-Ename->Vla-Object (car ent)))
Regards, HofCAD CSI.
Hi HofCAD CSI,
Thanx for your quick reply.
In addition to my previous post I have to add two more facts of my quest:
1. AutoCad R2002
2. I don't have access to VLAX components. Due to network restrictions this functionality will not register to OLE-part of the register.
In short : I will have to find my way in pure LISP.
Regards, E. Wijbrandts
kennet.sjoberg
2008-11-17, 11:41 PM
... 2. I don't have access to VLAX components. Due to network restrictions this functionality will not register to OLE-part of the register....
(vl-load-com) ?
: ) Happy Computing !
kennet
e.wijbrandts
2008-11-18, 08:19 AM
(vl-load-com) ?
: ) Happy Computing !
kennet
Hello Kennet,
Even the basic (vl-load-com) won't do. That's why I am trying to access the data with plain Lisp.
The unit I want to extract is an Autodesk Design Center 1070 group code within a BLOCK_RECORD. So in my humble opinion it should be possible to access this one with (entget (ent) '("ACAD")) or (entget (ent) '("*")).
greetz, Erik Wijbrandts
hofcad
2008-11-18, 05:01 PM
Hi HofCAD CSI,
Thanx for your quick reply.
In addition to my previous post I have to add two more facts of my quest:
1. AutoCad R2002
2. I don't have access to VLAX components. Due to network restrictions this functionality will not register to OLE-part of the register.
In short : I will have to find my way in pure LISP.
Regards, E. Wijbrandts
Sorry no AutoCad R2002,
But in AutoCAD 2008:
(defun c:test(/ Bname InsU slst)
(setq Bname (cdr (assoc 2 (entget (car (entsel))))))
(setq InsU (cdr (assoc 70 (entget (cdr (assoc 330 (entget(tblobjname "block" Bname))))))))
(setq slst (List "Unspecified" "Inches" "Feet" "Miles" "Millimeters"
"Centimeters" "Meters" "Kilometers" "Microinches" "Mils" "Yards"
"Angstroms" "Nanometers" "Microns" "Decimeters" "Dekameters"
"Hectometers" "Gigameters" "Astronomical Units" "Light Years" "Parsecs"))
(alert (strcat "Insunits are " (nth InsU slst)))
)
Regards HofCAD CSI.
e.wijbrandts
2008-11-18, 07:45 PM
Sorry no AutoCad R2002,
But in AutoCAD 2008:
(defun c:test(/ Bname InsU slst)
(setq Bname (cdr (assoc 2 (entget (car (entsel))))))
(setq InsU (cdr (assoc 70 (entget (cdr (assoc 330 (entget(tblobjname "block" Bname))))))))
(setq slst (List "Unspecified" "Inches" "Feet" "Miles" "Millimeters"
"Centimeters" "Meters" "Kilometers" "Microinches" "Mils" "Yards"
"Angstroms" "Nanometers" "Microns" "Decimeters" "Dekameters"
"Hectometers" "Gigameters" "Astronomical Units" "Light Years" "Parsecs"))
(alert (strcat "Insunits are " (nth InsU slst)))
)
Regards HofCAD CSI.
Hi HofCAD CSI,
THNX-A-LOT !! This is the one. It had to be something with "table". I knew it. :banghead:
As far as I'm concerned : case closed.
grtz & bedankt, Erik Wijbrandts
hofcad
2008-11-19, 09:29 AM
Hi HofCAD CSI,
THNX-A-LOT !! This is the one. It had to be something with "table". I knew it. :banghead:
As far as I'm concerned : case closed.
grtz & bedankt, Erik Wijbrandts
In AutoCAD 2002????
(defun c:test2002(/ Bname Xdata TmpL n Code Value slst)
(setq Bname (cdr (assoc 2 (entget (car (entsel))))))
(setq xdata (cdr (car (cdr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" bname)))) (list "*")))))))
(setq TmpL '())
(foreach n Xdata
(progn
(setq Code (car n))
(setq Value (cdr n))
(princ Value)
(if (= Code 1070) (setq TmpL (append TmpL (list Value))))
))
(setq slst (List "Unspecified" "Inches" "Feet" "Miles" "Millimeters"
"Centimeters" "Meters" "Kilometers" "Microinches" "Mils" "Yards"
"Angstroms" "Nanometers" "Microns" "Decimeters" "Dekameters"
"Hectometers" "Gigameters" "Astronomical Units" "Light Years" "Parsecs"))
(alert (strcat "Insunits are " (nth (cadr TmpL) slst)))
)
Can you try it out?
Regards, HofCAD CSI
e.wijbrandts
2008-11-19, 12:41 PM
In AutoCAD 2002????
(defun c:test2002(/ Bname Xdata TmpL n Code Value slst)
(setq Bname (cdr (assoc 2 (entget (car (entsel))))))
(setq xdata (cdr (car (cdr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" bname)))) (list "*")))))))
(setq TmpL '())
(foreach n Xdata
(progn
(setq Code (car n))
(setq Value (cdr n))
(princ Value)
(if (= Code 1070) (setq TmpL (append TmpL (list Value))))
))
(setq slst (List "Unspecified" "Inches" "Feet" "Miles" "Millimeters"
"Centimeters" "Meters" "Kilometers" "Microinches" "Mils" "Yards"
"Angstroms" "Nanometers" "Microns" "Decimeters" "Dekameters"
"Hectometers" "Gigameters" "Astronomical Units" "Light Years" "Parsecs"))
(alert (strcat "Insunits are " (nth (cadr TmpL) slst)))
)
Can you try it out?
Regards, HofCAD CSI
Hello HofCAD CSI,
I tested your code for c:TEST2002 together with a standard block. And the resulte are:
1. not applicable if no 3rd party XDATA is attached to the object
2. something simple as BLOCK UNIT is well hidden in "ACAD" XDATA while . . . . .
3. a more complex (multiline) DESCRIPTION is directly accessible through . . (cdr (assoc 4 (entget(tblobjname "block" Bname)))) . . .
What more specifics would you like to know ?
Regards, Erik Wijbrandts
hofcad
2008-11-19, 03:17 PM
Hello HofCAD CSI,
I tested your code for c:TEST2002 together with a standard block. And the resulte are:
1. not applicable if no 3rd party XDATA is attached to the object
2. something simple as BLOCK UNIT is well hidden in "ACAD" XDATA while . . . . .
3. a more complex (multiline) DESCRIPTION is directly accessible through . . (cdr (assoc 4 (entget(tblobjname "block" Bname)))) . . .
What more specifics would you like to know ?
Regards, Erik Wijbrandts
Erik,
I don't understand, because Test2002 works in AutoCAD 2002 at my place.
I get with
(setq xdata (cdr (car (cdr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" bname)))) (list "*")))))))
((1000 . "DesignCenter Data") (1002 . "{") (1070 . 1) (1070 . 15) (1002 . "}"))
The Insunits are 15 (Dekameters).
Which AutoCAD versions have the Insunits hidden in the Xdata?
Regards, HofCAD CSI.
PS For AutoCAD 2000 from http://www.autodesk.com/techpubs/autocad/acad2000/dxf/block95record_dxf_04.htm
Chapter 4 -- TABLES Section
--------------------------------------------------------------------------------
BLOCK_RECORD
--------------------------------------------------------------------------------
The following group codes apply to BLOCK_RECORD symbol table entries. In addition to the group codes described here, see "Common Group Codes for Symbol Table Entries." For information about abbreviations and formatting used in this table, see "Formatting Conventions in This Reference."
BLOCK_RECORD group codes
Group codes Description
100 Subclass marker (AcDbBlockTableRecord)
2 Block name
340 Hard-pointer ID/handle to associated LAYOUT object
310 DXF: Binary data for bitmap preview (optional)
1001 Xdata application name "ACAD" (optional)
1000 Xdata string data "DesignCenter Data" (optional)
1002 Begin xdata "{" (optional)
1070 Autodesk Design Center version number.
1070 Insert units:
0 = Unitless; 1 = Inches; 2 = Feet; 3 = Miles; 4 = Millimeters;
5 = Centimeters; 6 = Meters; 7 = Kilometers; 8 = Microinches;
9 = Mils; 10 = Yards; 11 = Angstroms; 12 = Nanometers;
13 = Microns; 14 = Decimeters; 15 = Decameters;
16 = Hectometers; 17 = Gigameters; 18 = Astronomical units;
19 = Light years; 20 = Parsecs
1002 End xdata "}"
e.wijbrandts
2008-11-19, 04:52 PM
Erik,
I don't understand, because Test2002 works in AutoCAD 2002 at my place.
I get with
(setq xdata (cdr (car (cdr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" bname)))) (list "*")))))))
((1000 . "DesignCenter Data") (1002 . "{") (1070 . 1) (1070 . 15) (1002 . "}"))
The Insunits are 15 (Dekameters).
Which AutoCAD versions have the Insunits hidden in the Xdata?
Regards, HofCAD CSI.
PS For AutoCAD 2000 from http://www.autodesk.com/techpubs/autocad/acad2000/dxf/block95record_dxf_04.htm
Chapter 4 -- TABLES Section
--------------------------------------------------------------------------------
BLOCK_RECORD
--------------------------------------------------------------------------------
The following group codes apply to BLOCK_RECORD symbol table entries. In addition to the group codes described here, see "Common Group Codes for Symbol Table Entries." For information about abbreviations and formatting used in this table, see "Formatting Conventions in This Reference."
BLOCK_RECORD group codes
Group codes Description
100 Subclass marker (AcDbBlockTableRecord)
2 Block name
340 Hard-pointer ID/handle to associated LAYOUT object
310 DXF: Binary data for bitmap preview (optional)
1001 Xdata application name "ACAD" (optional)
1000 Xdata string data "DesignCenter Data" (optional)
1002 Begin xdata "{" (optional)
1070 Autodesk Design Center version number.
1070 Insert units:
0 = Unitless; 1 = Inches; 2 = Feet; 3 = Miles; 4 = Millimeters;
5 = Centimeters; 6 = Meters; 7 = Kilometers; 8 = Microinches;
9 = Mils; 10 = Yards; 11 = Angstroms; 12 = Nanometers;
13 = Microns; 14 = Decimeters; 15 = Decameters;
16 = Hectometers; 17 = Gigameters; 18 = Astronomical units;
19 = Light years; 20 = Parsecs
1002 End xdata "}"
Hello HofCAD CSI,
While you are so persistent I ran the test again.
The code doesn't work when the InsertionUnits are initially set/kept to UNITLESS (0).
The code fails at (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" bname)))) (list "*")))
No XDATA attached at all.
At that moment I stopped during the previous test. Mea Culpa.
This time I set it at MILLIMETERS (4). To my surprise now XDATA is attached indeed.
((1000 . "DesignCenter Data") (1002 . "{") (1070 . 1) (1070 . 4) (1002 . "}"))
Switching several times to different units using the native Acad Block Definition Dialog works great, BUT....
It is in no way possible to put back at UNITLESS ?!?!?!
Conclusion
if no (1000 . "DesignCenter Data") XDATA available then INSUNITS = 0 ELSE INSUNITS > 0
Regards, Erik Wijbrandts
hofcad
2008-11-19, 05:51 PM
Hello HofCAD CSI,
Conclusion
if no (1000 . "DesignCenter Data") XDATA available then INSUNITS = 0 ELSE INSUNITS > 0
Regards, Erik Wijbrandts
Erik,
(defun c:test2002(/ Bname Xdata TmpL n Code Value Slst)
(setq Bname (cdr (assoc 2 (entget (car (entsel))))))
(setq Xdata (cdr (car (cdr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" Bname)))) (list "*")))))))
(if (= Xdata nil) (setq Tmpl '(0 0));Unitless
(progn
(setq TmpL '())
(foreach n Xdata
(progn
(setq Code (car n))
(setq Value (cdr n))
(princ Value)
(if (= Code 1070) (setq TmpL (append TmpL (list Value))))
))))
(setq Slst (List "Unspecified" "Inches" "Feet" "Miles" "Millimeters"
"Centimeters" "Meters" "Kilometers" "Microinches" "Mils" "Yards"
"Angstroms" "Nanometers" "Microns" "Decimeters" "Dekameters"
"Hectometers" "Gigameters" "Astronomical Units" "Light Years" "Parsecs"))
(alert (strcat "Insunits are " (nth (cadr TmpL) Slst)))
)
THNX-A-LOT !!
grtz & bedankt, HofCAD CSI
e.wijbrandts
2008-11-21, 12:06 PM
Erik,
(defun c:test2002(/ Bname Xdata TmpL n Code Value Slst)
(setq Bname (cdr (assoc 2 (entget (car (entsel))))))
(setq Xdata (cdr (car (cdr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" Bname)))) (list "*")))))))
(if (= Xdata nil) (setq Tmpl '(0 0));Unitless
(progn
(setq TmpL '())
(foreach n Xdata
(progn
(setq Code (car n))
(setq Value (cdr n))
(princ Value)
(if (= Code 1070) (setq TmpL (append TmpL (list Value))))
))))
(setq Slst (List "Unspecified" "Inches" "Feet" "Miles" "Millimeters"
"Centimeters" "Meters" "Kilometers" "Microinches" "Mils" "Yards"
"Angstroms" "Nanometers" "Microns" "Decimeters" "Dekameters"
"Hectometers" "Gigameters" "Astronomical Units" "Light Years" "Parsecs"))
(alert (strcat "Insunits are " (nth (cadr TmpL) Slst)))
)
THNX-A-LOT !!
grtz & bedankt, HofCAD CSI
Hello HofCAD CSI
THNX back-at-ya & grtz, Erik
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.