Author Topic: Help me, extract data Dynamic blocks and Attribute block to excel  (Read 5326 times)

0 Members and 1 Guest are viewing this topic.

minhphuong_humg

  • Mosquito
  • Posts: 11
Hello,
I have a drawing (attach) with Dynamic Blocks and Attribute Blocks.
Please, help me, write a lisp to extract data Dynamic blocks and Attribute block to Excel.
I used to Extraction Data in Autocad 2014 but don't expected.
Please, help me.
Thank you very much!

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Help me, extract data Dynamic blocks and Attribute block to excel
« Reply #1 on: January 13, 2014, 11:27:47 AM »
Here, try this and check attached *.csv - it's little different than your *.xls, but if you run the routine with step-by-step selections you may get desired result... The process is the same as Lnam.lsp posted here :

http://www.autolisp.com/forum/threads/892-Help-me-edit-complete-my-lisp!/page2&p=#11

Code - Auto/Visual Lisp: [Select]
  1. (defun round ( x )
  2.   (if (>= (- x (fix x)) 0.5)
  3.     (1+ (fix x))
  4.     (fix x)
  5.   )
  6. )
  7.  
  8. ;; Get Dynamic Block Property Value  -  Lee Mac
  9. ;; Returns the value of a Dynamic Block property (if present)
  10. ;; blk - [vla] VLA Dynamic Block Reference object
  11. ;; prp - [str] Dynamic Block property name (case-insensitive)
  12.  
  13. (defun LM:getdynpropvalue ( blk prp )
  14.   (setq prp (strcase prp))
  15.   (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
  16.     (vlax-invoke blk 'getdynamicblockproperties)
  17.   )
  18. )
  19.  
  20. (defun c:LNam-blk ( / ch dim ent f fname i loop pt ptdimlst pttxtlst s ss ssdim sstxt std std-m std-m-r std1 std1-m std1-m-r std2 std2-m std2-m-r stddlst stdmemb stl stt1 stt1-d stt2 stt2-d sttd sttn sttn1 sttn2 stxts txt )
  21.  
  22.  
  23.   (setq f (open (setq fname (strcat (getvar 'dwgprefix) "LNam-blk.csv")) "w"))
  24.   (setq loop t)
  25.   (while loop
  26.     (initget "Yes No")
  27.     (setq ch (getkword "\nStart/continue selecting data [Yes/No] <Yes>: "))
  28.     (if (or (eq ch "Yes") (eq ch nil))
  29.       (progn
  30.         (setq ss nil s nil)
  31.         (prompt "\nSelect desired branches with their specifications")
  32.         (while (not ss)
  33.           (setq ss (ssget))
  34.         )
  35.         (setq ssdim (ssadd))
  36.         (setq sstxt (ssadd))
  37.         (setq i -1)
  38.         (while (setq ent (ssname ss (setq i (1+ i))))
  39.           (cond
  40.             ( (and (eq (cdr (assoc 0 (entget ent))) "INSERT") (wcmatch (cdr (assoc 2 (entget ent))) "[*]*") (eq (vlax-get-property (vlax-ename->vla-object ent) 'EffectiveName) "DimPC"))
  41.               (ssadd ent ssdim)
  42.             )
  43.             ( (and (eq (cdr (assoc 0 (entget ent))) "INSERT") (eq (cdr (assoc 2 (entget ent))) "Buble"))
  44.               (ssadd ent sstxt)
  45.             )
  46.           )
  47.         )
  48.         (prompt "\nPick first dimension-dynamic block that has free end - starting dimension-dynamic block without starting end specification")
  49.         (while (not s)
  50.           (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
  51.         )
  52.         (setq std (ssname s 0))
  53.         (while std
  54.           (setq std-m (LM:getdynpropvalue (vlax-ename->vla-object std) "Distance1"))
  55.           (setq std-m-r (round std-m))
  56.           (setq std-a (polar (cdr (assoc 10 (entget std))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std) "Angle1") (vlax-get-property (vlax-ename->vla-object std) 'Rotation)) std-m))
  57.          
  58.           (setq i -1)
  59.           (while (setq txt (ssname sstxt (setq i (1+ i))))
  60.             (setq pt (cdr (assoc 10 (entget txt))))
  61.             (setq pttxtlst (cons (cons pt txt) pttxtlst))
  62.           )
  63.          
  64.           (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std-a (car a)) (distance std-a (car b)))))))))
  65.           (setq stt2 stt1)
  66.           (setq stt1-d nil)
  67.           (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  68.             (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  69.           )
  70.           (setq stt1-d (reverse stt1-d))
  71.           (setq sttn (car stt1-d))
  72.           (setq sttd (cdr stt1-d))
  73.           (setq sttd (apply 'strcat (mapcar '(lambda ( x ) (strcat "," x)) sttd)))
  74.          
  75.           (ssdel stt1 sstxt)
  76.           (setq pttxtlst nil)
  77.          
  78.           (setq stl (strcat sttn "," (itoa std-m-r) sttd))
  79.           (write-line stl f)
  80.           (setq sttn nil sttd nil stl nil)
  81.          
  82.           (ssdel std ssdim)
  83.  
  84.           (setq i -1)
  85.           (while (setq dim (ssname ssdim (setq i (1+ i))))
  86.             (setq pt (cdr (assoc 10 (entget dim))))
  87.             (setq ptdimlst (cons (cons pt dim) ptdimlst))
  88.           )
  89.          
  90.           (setq std1 (cdr (car (setq stdmemb (vl-member-if '(lambda ( x ) (equal (list (caar x) (cadar x)) (list (car std-a) (cadr std-a)) 0.5)) ptdimlst)))))
  91.           (setq std2 (cdr (car (vl-member-if '(lambda ( x ) (equal (list (caar x) (cadar x)) (list (car std-a) (cadr std-a)) 0.5)) (cdr stdmemb)))))
  92.  
  93.           (setq ptdimlst nil stdmemb nil)
  94.          
  95.           (if (and std1 std2)
  96.             (progn
  97.               (setq std1-m (LM:getdynpropvalue (vlax-ename->vla-object std1) "Distance1"))
  98.               (setq std1-m-r (round std1-m))
  99.               (setq std1-a (polar (cdr (assoc 10 (entget std1))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std1) "Angle1") (vlax-get-property (vlax-ename->vla-object std1) 'Rotation)) std1-m))
  100.          
  101.               (setq i -1)
  102.               (while (setq txt (ssname sstxt (setq i (1+ i))))
  103.                 (setq pt (cdr (assoc 10 (entget txt))))
  104.                 (setq pttxtlst (cons (cons pt txt) pttxtlst))
  105.               )
  106.              
  107.               (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std1-a (car a)) (distance std1-a (car b)))))))))
  108.               (setq stt2 stt1)
  109.               (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  110.                 (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  111.               )
  112.               (setq stt1-d (reverse stt1-d))
  113.               (setq sttn (car stt1-d))
  114.  
  115.               (setq sttn1 sttn)
  116.               (setq pttxtlst nil)
  117.              
  118.               (setq std2-m (LM:getdynpropvalue (vlax-ename->vla-object std2) "Distance1"))
  119.               (setq std2-m-r (round std2-m))
  120.               (setq std2-a (polar (cdr (assoc 10 (entget std2))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std2) "Angle1") (vlax-get-property (vlax-ename->vla-object std2) 'Rotation)) std2-m))
  121.  
  122.               (setq i -1)
  123.               (while (setq txt (ssname sstxt (setq i (1+ i))))
  124.                 (setq pt (cdr (assoc 10 (entget txt))))
  125.                 (setq pttxtlst (cons (cons pt txt) pttxtlst))
  126.               )
  127.              
  128.               (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std2-a (car a)) (distance std2-a (car b)))))))))
  129.               (setq stt2 stt1)
  130.               (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  131.                 (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  132.               )
  133.               (setq stt1-d (reverse stt1-d))
  134.               (setq sttn (car stt1-d))
  135.  
  136.               (setq sttn2 sttn)
  137.               (setq pttxtlst nil)
  138.              
  139.               (if (> (strlen sttn1) (strlen sttn2)) (setq std std1 stddlst (cons std2 stddlst)) (setq std std2 stddlst (cons std1 stddlst)))
  140.             )
  141.             (if std1 (setq std std1) (if stddlst (setq std (car stddlst) stddlst (cdr stddlst)) (setq std nil)))
  142.           )
  143.         )
  144.       )
  145.       (setq loop nil)
  146.     )
  147.   )
  148.   (close f)
  149.   (startapp "explorer" fname)
  150.   (princ)
  151. )
  152.  

M.R.
« Last Edit: January 13, 2014, 03:01:24 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

minhphuong_humg

  • Mosquito
  • Posts: 11
Re: Help me, extract data Dynamic blocks and Attribute block to excel
« Reply #2 on: January 13, 2014, 08:30:06 PM »
Here, try this and check attached *.csv - it's little different than your *.xls, but if you run the routine with step-by-step selections you may get desired result... The process is the same as Lnam.lsp posted here :

http://www.autolisp.com/forum/threads/892-Help-me-edit-complete-my-lisp!/page2&p=#11

Code - Auto/Visual Lisp: [Select]
  1. (defun round ( x )
  2.   (if (>= (- x (fix x)) 0.5)
  3.     (1+ (fix x))
  4.     (fix x)
  5.   )
  6. )
  7.  
  8. ;; Get Dynamic Block Property Value  -  Lee Mac
  9. ;; Returns the value of a Dynamic Block property (if present)
  10. ;; blk - [vla] VLA Dynamic Block Reference object
  11. ;; prp - [str] Dynamic Block property name (case-insensitive)
  12.  
  13. (defun LM:getdynpropvalue ( blk prp )
  14.   (setq prp (strcase prp))
  15.   (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
  16.     (vlax-invoke blk 'getdynamicblockproperties)
  17.   )
  18. )
  19.  
  20. (defun c:LNam-blk ( / ch dim ent f fname i loop pt ptdimlst pttxtlst s ss ssdim sstxt std std-m std-m-r std1 std1-m std1-m-r std2 std2-m std2-m-r stddlst stdmemb stl stt1 stt1-d stt2 stt2-d sttd sttn sttn1 sttn2 stxts txt )
  21.  
  22.  
  23.   (setq f (open (setq fname (strcat (getvar 'dwgprefix) "LNam-blk.csv")) "w"))
  24.   (setq loop t)
  25.   (while loop
  26.     (initget "Yes No")
  27.     (setq ch (getkword "\nStart/continue selecting data [Yes/No] <Yes>: "))
  28.     (if (or (eq ch "Yes") (eq ch nil))
  29.       (progn
  30.         (setq ss nil s nil)
  31.         (prompt "\nSelect desired branches with their specifications")
  32.         (while (not ss)
  33.           (setq ss (ssget))
  34.         )
  35.         (setq ssdim (ssadd))
  36.         (setq sstxt (ssadd))
  37.         (setq i -1)
  38.         (while (setq ent (ssname ss (setq i (1+ i))))
  39.           (cond
  40.             ( (and (eq (cdr (assoc 0 (entget ent))) "INSERT") (wcmatch (cdr (assoc 2 (entget ent))) "[*]*") (eq (vlax-get-property (vlax-ename->vla-object ent) 'EffectiveName) "DimPC"))
  41.               (ssadd ent ssdim)
  42.             )
  43.             ( (and (eq (cdr (assoc 0 (entget ent))) "INSERT") (eq (cdr (assoc 2 (entget ent))) "Buble"))
  44.               (ssadd ent sstxt)
  45.             )
  46.           )
  47.         )
  48.         (prompt "\nPick first dimension-dynamic block that has free end - starting dimension-dynamic block without starting end specification")
  49.         (while (not s)
  50.           (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
  51.         )
  52.         (setq std (ssname s 0))
  53.         (while std
  54.           (setq std-m (LM:getdynpropvalue (vlax-ename->vla-object std) "Distance1"))
  55.           (setq std-m-r (round std-m))
  56.           (setq std-a (polar (cdr (assoc 10 (entget std))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std) "Angle1") (vlax-get-property (vlax-ename->vla-object std) 'Rotation)) std-m))
  57.          
  58.           (setq i -1)
  59.           (while (setq txt (ssname sstxt (setq i (1+ i))))
  60.             (setq pt (cdr (assoc 10 (entget txt))))
  61.             (setq pttxtlst (cons (cons pt txt) pttxtlst))
  62.           )
  63.          
  64.           (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std-a (car a)) (distance std-a (car b)))))))))
  65.           (setq stt2 stt1)
  66.           (setq stt1-d nil)
  67.           (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  68.             (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  69.           )
  70.           (setq stt1-d (reverse stt1-d))
  71.           (setq sttn (car stt1-d))
  72.           (setq sttd (cdr stt1-d))
  73.           (setq sttd (apply 'strcat (mapcar '(lambda ( x ) (strcat "," x)) sttd)))
  74.          
  75.           (ssdel stt1 sstxt)
  76.           (setq pttxtlst nil)
  77.          
  78.           (setq stl (strcat sttn "," (itoa std-m-r) sttd))
  79.           (write-line stl f)
  80.           (setq sttn nil sttd nil stl nil)
  81.          
  82.           (ssdel std ssdim)
  83.  
  84.           (setq i -1)
  85.           (while (setq dim (ssname ssdim (setq i (1+ i))))
  86.             (setq pt (cdr (assoc 10 (entget dim))))
  87.             (setq ptdimlst (cons (cons pt dim) ptdimlst))
  88.           )
  89.          
  90.           (setq std1 (cdr (car (setq stdmemb (vl-member-if '(lambda ( x ) (equal (list (caar x) (cadar x)) (list (car std-a) (cadr std-a)) 0.5)) ptdimlst)))))
  91.           (setq std2 (cdr (car (vl-member-if '(lambda ( x ) (equal (list (caar x) (cadar x)) (list (car std-a) (cadr std-a)) 0.5)) (cdr stdmemb)))))
  92.  
  93.           (setq ptdimlst nil stdmemb nil)
  94.          
  95.           (if (and std1 std2)
  96.             (progn
  97.               (setq std1-m (LM:getdynpropvalue (vlax-ename->vla-object std1) "Distance1"))
  98.               (setq std1-m-r (round std1-m))
  99.               (setq std1-a (polar (cdr (assoc 10 (entget std1))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std1) "Angle1") (vlax-get-property (vlax-ename->vla-object std1) 'Rotation)) std1-m))
  100.          
  101.               (setq i -1)
  102.               (while (setq txt (ssname sstxt (setq i (1+ i))))
  103.                 (setq pt (cdr (assoc 10 (entget txt))))
  104.                 (setq pttxtlst (cons (cons pt txt) pttxtlst))
  105.               )
  106.              
  107.               (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std1-a (car a)) (distance std1-a (car b)))))))))
  108.               (setq stt2 stt1)
  109.               (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  110.                 (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  111.               )
  112.               (setq stt1-d (reverse stt1-d))
  113.               (setq sttn (car stt1-d))
  114.  
  115.               (setq sttn1 sttn)
  116.               (setq pttxtlst nil)
  117.              
  118.               (setq std2-m (LM:getdynpropvalue (vlax-ename->vla-object std2) "Distance1"))
  119.               (setq std2-m-r (round std2-m))
  120.               (setq std2-a (polar (cdr (assoc 10 (entget std2))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std2) "Angle1") (vlax-get-property (vlax-ename->vla-object std2) 'Rotation)) std2-m))
  121.  
  122.               (setq i -1)
  123.               (while (setq txt (ssname sstxt (setq i (1+ i))))
  124.                 (setq pt (cdr (assoc 10 (entget txt))))
  125.                 (setq pttxtlst (cons (cons pt txt) pttxtlst))
  126.               )
  127.              
  128.               (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std2-a (car a)) (distance std2-a (car b)))))))))
  129.               (setq stt2 stt1)
  130.               (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  131.                 (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  132.               )
  133.               (setq stt1-d (reverse stt1-d))
  134.               (setq sttn (car stt1-d))
  135.  
  136.               (setq sttn2 sttn)
  137.               (setq pttxtlst nil)
  138.              
  139.               (if (> (strlen sttn1) (strlen sttn2)) (setq std std1 stddlst (cons std2 stddlst)) (setq std std2 stddlst (cons std1 stddlst)))
  140.             )
  141.             (if std1 (setq std std1) (if stddlst (setq std (car stddlst) stddlst (cdr stddlst)) (setq std nil)))
  142.           )
  143.         )
  144.       )
  145.       (setq loop nil)
  146.     )
  147.   )
  148.   (close f)
  149.   (startapp "explorer" fname)
  150.   (princ)
  151. )
  152.  

M.R.
Thank for help.
When I used coincides with the LMAN (Layer State Mannager) command (Autocad 2014). Please, help me change to other command.
Thank you very much.
P / S: You can fix the sort by number
1
2
3
....
then to
1.1
1.2
1.3
  .....
been is not?
instead
1
1.1
1.2
1.3
2
3
Means:
Sort an integer first then up to the number of Odd after.
Please, help me. Thank you very much.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Help me, extract data Dynamic blocks and Attribute block to excel
« Reply #3 on: January 14, 2014, 04:10:17 AM »
Thank for help.
When I used coincides with the LMAN (Layer State Mannager) command (Autocad 2014). Please, help me change to other command.

Routine starts with : LNam-blk - it's totally different than LMAN, I've checked it in A2014 and both things work fine...

Thank you very much.
P / S: You can fix the sort by number
1
2
3
....
then to
1.1
1.2
1.3
  .....
been is not?
instead
1
1.1
1.2
1.3
2
3
Means:
Sort an integer first then up to the number of Odd after.
Please, help me.

Populating EXCEL *.csv file is done in relation with branching in reference DWG... If you perform routine command step-by-step, selecting desired branch/es and starting dimension-dynamic block and then continue with the same procedure answering "Yes" for question to continue populating, you'll get at the end what you wanted without sorting, just answer in the end "No"... Otherwise, I am afraid, if you are not patient and you want to process all blocks in singe shot, you may get *.csv like I posted and you'll have to do sorting inside EXCEL, which is what I strongly suggest, and that is the best way of managing data to be in desired form...

Thank you very much.

You're very welcome, minhphuong_humg...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

minhphuong_humg

  • Mosquito
  • Posts: 11
Re: Help me, extract data Dynamic blocks and Attribute block to excel
« Reply #4 on: January 14, 2014, 04:14:33 AM »
Thank for help.
When I used coincides with the LMAN (Layer State Mannager) command (Autocad 2014). Please, help me change to other command.

Thank for help.
When I used coincides with the LMAN (Layer State Mannager) command (Autocad 2014). Please, help me change to other command.

Routine starts with : LNam-blk - it's totally different than LMAN, I've checked it in A2014 and both things work fine...

Thank you very much.
P / S: You can fix the sort by number
1
2
3
....
then to
1.1
1.2
1.3
  .....
been is not?
instead
1
1.1
1.2
1.3
2
3
Means:
Sort an integer first then up to the number of Odd after.
Please, help me.

Populating EXCEL *.csv file is done in relation with branching in reference DWG... If you perform routine command step-by-step, selecting desired branch/es and starting dimension-dynamic block and then continue with the same procedure answering "Yes" for question to continue populating, you'll get at the end what you wanted without sorting, just answer in the end "No"... Otherwise, I am afraid, if you are not patient and you want to process all blocks in singe shot, you may get *.csv like I posted and you'll have to do sorting inside EXCEL, which is what I strongly suggest, and that is the best way of managing data to be in desired form...

Thank you very much.

You're very welcome, minhphuong_humg...

M.R.

Thank you very much.
P / S: You can fix the sort by number
1
2
3
....
then to
1.1
1.2
1.3
  .....
been is not?
instead
1
1.1
1.2
1.3
2
3
Means:
Sort an integer first then up to the number of Odd after.
Please, help me.

Populating EXCEL *.csv file is done in relation with branching in reference DWG... If you perform routine command step-by-step, selecting desired branch/es and starting dimension-dynamic block and then continue with the same procedure answering "Yes" for question to continue populating, you'll get at the end what you wanted without sorting, just answer in the end "No"... Otherwise, I am afraid, if you are not patient and you want to process all blocks in singe shot, you may get *.csv like I posted and you'll have to do sorting inside EXCEL, which is what I strongly suggest, and that is the best way of managing data to be in desired form...

Thank you very much.

You're very welcome, minhphuong_humg...

M.R.
Oh, thank you very much.
Your lisp work fine.
Final, goodluck for you.

minhphuong_humg

  • Mosquito
  • Posts: 11
Re: Help me, extract data Dynamic blocks and Attribute block to excel
« Reply #5 on: January 26, 2014, 10:45:38 AM »
Here, try this and check attached *.csv - it's little different than your *.xls, but if you run the routine with step-by-step selections you may get desired result... The process is the same as Lnam.lsp posted here :

http://www.autolisp.com/forum/threads/892-Help-me-edit-complete-my-lisp!/page2&p=#11

Code - Auto/Visual Lisp: [Select]
  1. (defun round ( x )
  2.   (if (>= (- x (fix x)) 0.5)
  3.     (1+ (fix x))
  4.     (fix x)
  5.   )
  6. )
  7.  
  8. ;; Get Dynamic Block Property Value  -  Lee Mac
  9. ;; Returns the value of a Dynamic Block property (if present)
  10. ;; blk - [vla] VLA Dynamic Block Reference object
  11. ;; prp - [str] Dynamic Block property name (case-insensitive)
  12.  
  13. (defun LM:getdynpropvalue ( blk prp )
  14.   (setq prp (strcase prp))
  15.   (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
  16.     (vlax-invoke blk 'getdynamicblockproperties)
  17.   )
  18. )
  19.  
  20. (defun c:LNam-blk ( / ch dim ent f fname i loop pt ptdimlst pttxtlst s ss ssdim sstxt std std-m std-m-r std1 std1-m std1-m-r std2 std2-m std2-m-r stddlst stdmemb stl stt1 stt1-d stt2 stt2-d sttd sttn sttn1 sttn2 stxts txt )
  21.  
  22.  
  23.   (setq f (open (setq fname (strcat (getvar 'dwgprefix) "LNam-blk.csv")) "w"))
  24.   (setq loop t)
  25.   (while loop
  26.     (initget "Yes No")
  27.     (setq ch (getkword "\nStart/continue selecting data [Yes/No] <Yes>: "))
  28.     (if (or (eq ch "Yes") (eq ch nil))
  29.       (progn
  30.         (setq ss nil s nil)
  31.         (prompt "\nSelect desired branches with their specifications")
  32.         (while (not ss)
  33.           (setq ss (ssget))
  34.         )
  35.         (setq ssdim (ssadd))
  36.         (setq sstxt (ssadd))
  37.         (setq i -1)
  38.         (while (setq ent (ssname ss (setq i (1+ i))))
  39.           (cond
  40.             ( (and (eq (cdr (assoc 0 (entget ent))) "INSERT") (wcmatch (cdr (assoc 2 (entget ent))) "[*]*") (eq (vlax-get-property (vlax-ename->vla-object ent) 'EffectiveName) "DimPC"))
  41.               (ssadd ent ssdim)
  42.             )
  43.             ( (and (eq (cdr (assoc 0 (entget ent))) "INSERT") (eq (cdr (assoc 2 (entget ent))) "Buble"))
  44.               (ssadd ent sstxt)
  45.             )
  46.           )
  47.         )
  48.         (prompt "\nPick first dimension-dynamic block that has free end - starting dimension-dynamic block without starting end specification")
  49.         (while (not s)
  50.           (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
  51.         )
  52.         (setq std (ssname s 0))
  53.         (while std
  54.           (setq std-m (LM:getdynpropvalue (vlax-ename->vla-object std) "Distance1"))
  55.           (setq std-m-r (round std-m))
  56.           (setq std-a (polar (cdr (assoc 10 (entget std))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std) "Angle1") (vlax-get-property (vlax-ename->vla-object std) 'Rotation)) std-m))
  57.          
  58.           (setq i -1)
  59.           (while (setq txt (ssname sstxt (setq i (1+ i))))
  60.             (setq pt (cdr (assoc 10 (entget txt))))
  61.             (setq pttxtlst (cons (cons pt txt) pttxtlst))
  62.           )
  63.          
  64.           (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std-a (car a)) (distance std-a (car b)))))))))
  65.           (setq stt2 stt1)
  66.           (setq stt1-d nil)
  67.           (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  68.             (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  69.           )
  70.           (setq stt1-d (reverse stt1-d))
  71.           (setq sttn (car stt1-d))
  72.           (setq sttd (cdr stt1-d))
  73.           (setq sttd (apply 'strcat (mapcar '(lambda ( x ) (strcat "," x)) sttd)))
  74.          
  75.           (ssdel stt1 sstxt)
  76.           (setq pttxtlst nil)
  77.          
  78.           (setq stl (strcat sttn "," (itoa std-m-r) sttd))
  79.           (write-line stl f)
  80.           (setq sttn nil sttd nil stl nil)
  81.          
  82.           (ssdel std ssdim)
  83.  
  84.           (setq i -1)
  85.           (while (setq dim (ssname ssdim (setq i (1+ i))))
  86.             (setq pt (cdr (assoc 10 (entget dim))))
  87.             (setq ptdimlst (cons (cons pt dim) ptdimlst))
  88.           )
  89.          
  90.           (setq std1 (cdr (car (setq stdmemb (vl-member-if '(lambda ( x ) (equal (list (caar x) (cadar x)) (list (car std-a) (cadr std-a)) 0.5)) ptdimlst)))))
  91.           (setq std2 (cdr (car (vl-member-if '(lambda ( x ) (equal (list (caar x) (cadar x)) (list (car std-a) (cadr std-a)) 0.5)) (cdr stdmemb)))))
  92.  
  93.           (setq ptdimlst nil stdmemb nil)
  94.          
  95.           (if (and std1 std2)
  96.             (progn
  97.               (setq std1-m (LM:getdynpropvalue (vlax-ename->vla-object std1) "Distance1"))
  98.               (setq std1-m-r (round std1-m))
  99.               (setq std1-a (polar (cdr (assoc 10 (entget std1))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std1) "Angle1") (vlax-get-property (vlax-ename->vla-object std1) 'Rotation)) std1-m))
  100.          
  101.               (setq i -1)
  102.               (while (setq txt (ssname sstxt (setq i (1+ i))))
  103.                 (setq pt (cdr (assoc 10 (entget txt))))
  104.                 (setq pttxtlst (cons (cons pt txt) pttxtlst))
  105.               )
  106.              
  107.               (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std1-a (car a)) (distance std1-a (car b)))))))))
  108.               (setq stt2 stt1)
  109.               (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  110.                 (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  111.               )
  112.               (setq stt1-d (reverse stt1-d))
  113.               (setq sttn (car stt1-d))
  114.  
  115.               (setq sttn1 sttn)
  116.               (setq pttxtlst nil)
  117.              
  118.               (setq std2-m (LM:getdynpropvalue (vlax-ename->vla-object std2) "Distance1"))
  119.               (setq std2-m-r (round std2-m))
  120.               (setq std2-a (polar (cdr (assoc 10 (entget std2))) (+ (LM:getdynpropvalue (vlax-ename->vla-object std2) "Angle1") (vlax-get-property (vlax-ename->vla-object std2) 'Rotation)) std2-m))
  121.  
  122.               (setq i -1)
  123.               (while (setq txt (ssname sstxt (setq i (1+ i))))
  124.                 (setq pt (cdr (assoc 10 (entget txt))))
  125.                 (setq pttxtlst (cons (cons pt txt) pttxtlst))
  126.               )
  127.              
  128.               (setq stt1 (cdr (car (setq stxts (vl-sort pttxtlst '(lambda ( a b ) (< (distance std2-a (car a)) (distance std2-a (car b)))))))))
  129.               (setq stt2 stt1)
  130.               (while (/= (cdr (assoc 0 (entget (setq stt2 (entnext stt2))))) "SEQEND")
  131.                 (setq stt1-d (cons (cdr (assoc 1 (entget stt2))) stt1-d))
  132.               )
  133.               (setq stt1-d (reverse stt1-d))
  134.               (setq sttn (car stt1-d))
  135.  
  136.               (setq sttn2 sttn)
  137.               (setq pttxtlst nil)
  138.              
  139.               (if (> (strlen sttn1) (strlen sttn2)) (setq std std1 stddlst (cons std2 stddlst)) (setq std std2 stddlst (cons std1 stddlst)))
  140.             )
  141.             (if std1 (setq std std1) (if stddlst (setq std (car stddlst) stddlst (cdr stddlst)) (setq std nil)))
  142.           )
  143.         )
  144.       )
  145.       (setq loop nil)
  146.     )
  147.   )
  148.   (close f)
  149.   (startapp "explorer" fname)
  150.   (princ)
  151. )
  152.  

M.R.

Dir, Ribarm!
Thanks for the help Ribarm times before.
Howerver, I am also a large number of drawings has not been transferred to the Dynamic Block. It is still in the form of Aligned Dimension. Please edit your AutoLISP little I can do to help you draw out the rest before I switched to Dynamic Block? I changed the order number in the Attribute Block.
Please help me.
Thank Ribarm very much!