Visual LISP, AutoLISP and General Customization
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Obtaining Dynamic Block info using Lisp
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
359 Views, 2 Replies
05-11-2009 06:12 AM
My goal is to be able to retrieve this info using lisp. This is what I can do so far...
This drawing has a single dynamic block in it called "Label - 200 to 50x20mm"
If you select it and check out the properties, you will see that under the "Custom" heading that there is a "visibility" property which you can select to be one of the followng:
200x20mm
150x20mm
100x20mm
75x20mm
50x20mm
If you type or copy the following lisp into the command line:
(Setq Ent (entget (Setq EntName (ssname (Setq Handle(ssget)) 0))))
& then select the block and press enter, you get the following info:
((-1 .) (0 . "INSERT") (5 . "1AA") (102 .
"{ACAD_XDICTIONARY") (360 .) (102 . "}") (330 .
name: 7eaf9cf8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
"AcDbBlockReference") (66 . 1) (2 . "*U9") (10 -15.403 -5.69862 0.0) (41 . 1.0)
(42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210
0.0 0.0 1.0))
The name of the block is some reference name like:
(2 . "*U9")
To get the real name, copy and paste the following onto the command line:
(progn
(Setq DictName (cdr (assoc 360 Ent))) ;Get the Dictionary Name from the Entity
(Setq Dict (entget DictName)) ;Get the Dictionary from the Dictionary Name
(setq Dict1 (entget (setq Dict1Name (cdr (assoc 360 Dict )))))
(setq Dict2 (entget (setq Dict2Name (cdr (assoc 360 Dict1)))))
(setq Block (entget (setq BlockName (cdr (assoc 340 Dict2)))))
(cdr (assoc 2 Block))
)
which returns:
"Label - 200 to 50x20mm"
Next I can get the attributes (1 at a time) using the following code:
(Setq Ent (entget (Setq EntName (entnext EntName))))
which returns:
((-1 .) (0 . "ATTRIB") (330 . )
(5 . "1AB") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PARTS") (100 .
"AcDbText") (10 -20.8887 -2.19862 0.0) (40 . 3.0) (1 . "Text 1") (50 . 0.0) (41
. 0.8) (51 . 0.0) (7 . "ROMANS") (71 . 0) (72 . 1) (11 -15.403 -0.698618 0.0)
(210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "TEXTLINE1_1") (70 . 8) (73 . 0)
i.e. the first attribute's name is "TEXTLINE1_1", and it contains the value of "Text 1"
run that command again (while in the command line press the up arrow key) and you get the second attributes details:
((-1 .) (0 . "ATTRIB") (330 . )
(5 . "1AC") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PARTS") (100 .
"AcDbText") (10 -21.2316 -7.19862 0.0) (40 . 3.0) (1 . "Text 2") (50 . 0.0) (41
. 0.8) (51 . 0.0) (7 . "ROMANS") (71 . 0) (72 . 1) (11 -15.403 -5.69862 0.0)
(210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "TEXTLINE1_2") (70 . 8) (73 . 0)
(74 . 2))
i.e. the second attribute's name is "TEXTLINE1_2", and it contains the value of "Text 2"
run that command again (while in the command line press the up arrow key) and you get the third (final) attributes details:
((-1 .) (0 . "ATTRIB") (330 . )
(5 . "1AD") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PARTS") (100 .
"AcDbText") (10 -21.2316 -12.1986 0.0) (40 . 3.0) (1 . "Text 3") (50 . 0.0) (41
. 0.8) (51 . 0.0) (7 . "ROMANS") (71 . 0) (72 . 1) (11 -15.403 -10.6986 0.0)
(210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "TEXTLINE1_3") (70 . 8) (73 . 0)
(74 . 2))
i.e. the third attribute's name is "TEXTLINE1_3", and it contains the value of "Text 3"
However, that is as far as I get! ! !
?????????????????????????????????????????????????? ?????????????????????????????????
How do I obtain the current visibility state as seen in the objects properties, i.e. "100x20mm" for example?
?????????????????????????????????????????????????? ?????????????????????????????????
This drawing has a single dynamic block in it called "Label - 200 to 50x20mm"
If you select it and check out the properties, you will see that under the "Custom" heading that there is a "visibility" property which you can select to be one of the followng:
200x20mm
150x20mm
100x20mm
75x20mm
50x20mm
If you type or copy the following lisp into the command line:
(Setq Ent (entget (Setq EntName (ssname (Setq Handle(ssget)) 0))))
& then select the block and press enter, you get the following info:
((-1 .
"{ACAD_XDICTIONARY") (360 .
name: 7eaf9cf8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
"AcDbBlockReference") (66 . 1) (2 . "*U9") (10 -15.403 -5.69862 0.0) (41 . 1.0)
(42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210
0.0 0.0 1.0))
The name of the block is some reference name like:
(2 . "*U9")
To get the real name, copy and paste the following onto the command line:
(progn
(Setq DictName (cdr (assoc 360 Ent))) ;Get the Dictionary Name from the Entity
(Setq Dict (entget DictName)) ;Get the Dictionary from the Dictionary Name
(setq Dict1 (entget (setq Dict1Name (cdr (assoc 360 Dict )))))
(setq Dict2 (entget (setq Dict2Name (cdr (assoc 360 Dict1)))))
(setq Block (entget (setq BlockName (cdr (assoc 340 Dict2)))))
(cdr (assoc 2 Block))
)
which returns:
"Label - 200 to 50x20mm"
Next I can get the attributes (1 at a time) using the following code:
(Setq Ent (entget (Setq EntName (entnext EntName))))
which returns:
((-1 .
(5 . "1AB") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PARTS") (100 .
"AcDbText") (10 -20.8887 -2.19862 0.0) (40 . 3.0) (1 . "Text 1") (50 . 0.0) (41
. 0.8) (51 . 0.0) (7 . "ROMANS") (71 . 0) (72 . 1) (11 -15.403 -0.698618 0.0)
(210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "TEXTLINE1_1") (70 . 8) (73 . 0)
i.e. the first attribute's name is "TEXTLINE1_1", and it contains the value of "Text 1"
run that command again (while in the command line press the up arrow key) and you get the second attributes details:
((-1 .
(5 . "1AC") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PARTS") (100 .
"AcDbText") (10 -21.2316 -7.19862 0.0) (40 . 3.0) (1 . "Text 2") (50 . 0.0) (41
. 0.8) (51 . 0.0) (7 . "ROMANS") (71 . 0) (72 . 1) (11 -15.403 -5.69862 0.0)
(210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "TEXTLINE1_2") (70 . 8) (73 . 0)
(74 . 2))
i.e. the second attribute's name is "TEXTLINE1_2", and it contains the value of "Text 2"
run that command again (while in the command line press the up arrow key) and you get the third (final) attributes details:
((-1 .
(5 . "1AD") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PARTS") (100 .
"AcDbText") (10 -21.2316 -12.1986 0.0) (40 . 3.0) (1 . "Text 3") (50 . 0.0) (41
. 0.8) (51 . 0.0) (7 . "ROMANS") (71 . 0) (72 . 1) (11 -15.403 -10.6986 0.0)
(210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "TEXTLINE1_3") (70 . 8) (73 . 0)
(74 . 2))
i.e. the third attribute's name is "TEXTLINE1_3", and it contains the value of "Text 3"
However, that is as far as I get! ! !
??????????????????????????????????????????????????
How do I obtain the current visibility state as seen in the objects properties, i.e. "100x20mm" for example?
??????????????????????????????????????????????????
Re: Obtaining Dynamic Block info using Lisp
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-11-2009 07:33 AM in reply to:
exue
Hi,
You can do it with
You can do it with
(DynamicProps (car (entsel)) "Visibility" nil)
This give something like:
(("100X20mm" ("200x20mm" "150x20mm" "100x20mm" "75x20mm" "50x20mm" )))
Where the first of the list is the current state
Change the visibilty with
(DynamicProps (car (entsel)) "Visibility" "200x20mm")
Hope this helps
Harrie
Re: Obtaining Dynamic Block info using Lisp
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-12-2009 11:32 PM in reply to:
exue
Hi Harri
Thanks very much, that was exactly what I was looking for.
Regards
Thanks very much, that was exactly what I was looking for.
Regards
