Author Topic: HELP! I just want to add bliock at one endpoint of lines,plines,arc!NOT TWO END  (Read 4104 times)

0 Members and 1 Guest are viewing this topic.

meja

  • Newt
  • Posts: 47
I have get code like this
Code - Auto/Visual Lisp: [Select]
  1. ;;; ENDTICK.LSP
  2. ;;;
  3. ;;; Copyright 2006 Thomas Gail Haws
  4. ;;; This program is free software under the terms of the
  5. ;;; GNU (GNU--acronym for Gnu's Not Unix--sounds like canoe)
  6. ;;; General Public License as published by the Free Software Foundation,
  7. ;;; version 2 of the License.
  8. ;;;
  9. ;;; You can redistribute this software for any fee or no fee and/or
  10. ;;; modify it in any way, but it and ANY MODIFICATIONS OR DERIVATIONS
  11. ;;; continue to be governed by the license, which protects the perpetual
  12. ;;; availability of the software for free distribution and modification.
  13. ;;;
  14. ;;; You CAN'T put this code into any proprietary package.  Read the license.
  15. ;;;
  16. ;;; If you improve this software, please make a revision submittal to the
  17. ;;; copyright owner at www.hawsedc.com.
  18. ;;;
  19. ;;; This program is distributed in the hope that it will be useful,
  20. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. ;;; GNU General Public License on the World Wide Web for more details.
  23. ;;;
  24. ;;; DESCRIPTION
  25. ;;;
  26. ;;; ENDTICK inserts and aligns the ENDTICK block at the endpoint of every arc or line
  27. ;;; in a selection set.  It removes duplicate ticks.
  28. ;;;
  29. ;;; ENDTICK is useful for surveying and civil engineering plans to demarcate points of
  30. ;;; curvature, tangency, et cetera.
  31. ;;;
  32. ;;; You can make your own ENDTICK block if you prefer some custom shape or size tick.
  33. ;;; The default ENDTICK block is a one unit long vertical line with its insertion point
  34. ;;; at its midpoint.  ENDTICK scales the ticks to the dimension text height
  35. ;;; (dimscale * dimtext), so the default ENDTICK block will look as big as the current
  36. ;;; dimension text height.
  37. ;;;
  38. ;;; Revisions
  39. ;;; 20060914  TGH   Version 1.0PR released.  3 hrs.  Works only with world UCS and View
  40.  
  41. ;;; Modified by Irn?Barnard on 2010-01-15 to allow for polylines as well, noted with comments starting with IB:
  42.  
  43. (vl-load-com) ;IB: Ensure VLisp extensions are loaded
  44.  
  45. (setq EndTick:BlkName "endtick") ;IB: Change this if block's name is different
  46.  
  47. (defun c:ENDTICK () (ENDTICK))
  48.  
  49. (defun ENDTICK ;;No global variables.  All the variables should be listed here as local.
  50.                (/           CENPOINT    DS          DT          ENDANG      ENDPOINT    ENTLIST     ENTNAME
  51.                 ENTTYPE     I           MINTICKSEPARATION       RADIUS      SS1         STARTANG    STARTPOINT
  52.                 TICKLIST    TS          ENTOBJ ;IB: Added ENTOBJ for ActiveX object reference
  53.                )
  54.   ;;Set initial variables
  55.   (setq ds                (getvar "dimscale")
  56.         dt                (getvar "dimtxt")
  57.         ts                (* ds dt)
  58.         ;;If endpoints are closer together than the distance given below
  59.         ;; and also aligned angularly closer than the angular difference below,
  60.         ;; ENDTICK only plots the first one of them it finds.
  61.         mintickseparation (* ts 0.01)
  62.         ;;In radians.  Setting to some big number like 10 (larger than 2 pi) will remove coincident ticks even with different rotations.
  63.         mintickangulardif 0.01
  64.   ) ;_ end of setq
  65.   ;;Get selection set from user.  Limit to lines and arcs.
  66.   (setq ss1 (ssget '((0 . "LINE,ARC,LWPOLYLINE,POLYLINE"))) ;IB: Added LWPOLYLINE and POLYLINE
  67.         i   -1
  68.   ) ;_ end of setq
  69.   ;;Get endpoints and orientations from selection set
  70.   (while (setq entname (ssname ss1 (setq i (1+ i))))
  71.     (setq
  72.       entlist (entget entname)
  73.       enttype (cdr (assoc 0 entlist))
  74.     ) ;_ end of setq
  75.     (cond
  76.       ((= enttype "LINE")
  77.        (setq
  78.          startpoint (cdr (assoc 10 entlist))
  79.          endpoint   (cdr (assoc 11 entlist))
  80.          ticklist   (ENDTICK-addtolist
  81.                       (list startpoint (angle startpoint endpoint))
  82.                       ticklist
  83.                       mintickseparation
  84.                       mintickangulardif
  85.                     ) ;_ end of ENDTICK-addtolist
  86.          ticklist   (ENDTICK-addtolist
  87.                       (list
  88.                         endpoint
  89.                         (angle endpoint startpoint)
  90.                       ) ;_ end of list
  91.                       ticklist
  92.                       mintickseparation
  93.                       mintickangulardif
  94.                     ) ;_ end of ENDTICK-addtolist
  95.        ) ;_ end of setq
  96.       )
  97.  
  98.       ((= enttype "ARC")
  99.        (setq
  100.          cenpoint   (cdr (assoc 10 entlist))
  101.          radius     (cdr (assoc 40 entlist))
  102.          startang   (cdr (assoc 50 entlist))
  103.          endang     (cdr (assoc 51 entlist))
  104.          startpoint (polar cenpoint startang radius)
  105.          endpoint   (polar cenpoint endang radius)
  106.          ticklist   (ENDTICK-addtolist
  107.                       (list startpoint (+ startang (/ pi 2)))
  108.                       ticklist
  109.                       mintickseparation
  110.                       mintickangulardif
  111.                     ) ;_ end of ENDTICK-addtolist
  112.          ticklist   (ENDTICK-addtolist
  113.                       (list endpoint (+ endang (/ pi 2)))
  114.                       ticklist
  115.                       mintickseparation
  116.                       mintickangulardif
  117.                     ) ;_ end of ENDTICK-addtolist
  118.        ) ;_ end of setq
  119.       )
  120.  
  121.       ;; IB: Section added to do Polyline's
  122.       ((wcmatch enttype "LWPOLYLINE,POLYLINE")
  123.        (setq
  124.          ENTOBJ     (vlax-ename->vla-object entname) ;Get the ActiveX object reference from the ename
  125.          startpoint (vlax-curve-getStartPoint ENTOBJ) ;Get the start point
  126.          endpoint   (vlax-curve-getEndPoint ENTOBJ) ;Get the end point
  127.          startang   (angle '(0.0 0.0 0.0) ;Get the start angle
  128.                            (vlax-curve-getFirstDeriv ENTOBJ (vlax-curve-getStartParam ENTOBJ))
  129.                     ) ;_ end of angle
  130.          endang     (angle '(0.0 0.0 0.0) ;Get the end angle
  131.                            (vlax-curve-getFirstDeriv ENTOBJ (vlax-curve-getEndParam ENTOBJ))
  132.                     ) ;_ end of angle
  133.          ticklist   (ENDTICK-addtolist
  134.                       (list startpoint (+ startang (/ pi 2)))
  135.                       ticklist
  136.                       mintickseparation
  137.                       mintickangulardif
  138.                     ) ;_ end of ENDTICK-addtolist
  139.          ticklist   (ENDTICK-addtolist
  140.                       (list endpoint (+ endang (/ pi 2)))
  141.                       ticklist
  142.                       mintickseparation
  143.                       mintickangulardif
  144.                     ) ;_ end of ENDTICK-addtolist
  145.        ) ;_ end of setq
  146.       ) ;IB: End of section added
  147.     ) ;_ end of cond
  148.   ) ;_ end of while
  149.   (setq auold (getvar "aunits"))
  150.   (setvar "aunits" 3)
  151.   ;; IB: Modified to suit both uniform and non-uniform scaled blocks
  152.   (if (and (tblsearch "BLOCK" EndTick:BlkName)
  153.                               EndTick:BlkName
  154.                     ) ;_ end of vla-Item
  155.            ) ;_ end of setq
  156.       ) ;_ end of and
  157.     (if (= (vla-get-BlockScaling DS) 0)
  158.       ;; If non Uniform scaling
  159.       (foreach tick ticklist
  160.         (command "._insert" EndTick:BlkName (car tick) ts "" (cadr tick))
  161.       ) ;_ end of foreach
  162.       ;; Else with uniform scaling
  163.       (foreach tick ticklist
  164.         (command "._insert" EndTick:BlkName (car tick) ts (cadr tick))
  165.       ) ;_ end of foreach
  166.     ) ;_ end of if
  167.     (princ
  168.       (strcat
  169.         "Please note, block ["
  170.         EndTick:BlkName
  171.         "] is not available in this drawing. Change the name used in the LSP file or insert the block to this drawing."
  172.       ) ;_ end of strcat
  173.     ) ;_ end of princ
  174.   ) ;_ end of if
  175.   (setvar "aunits" auold)
  176. ) ;_ end of defun
  177.  
  178. ;; IB: Added function to convert Radians to Degrees
  179. (defun Rad2Deg (Rad /) (* 180.0 (/ Rad pi)))
  180.  
  181. (defun ENDTICK-addtolist (tick ticklist mintickseparation mintickangulardif / dupfound templist tickcheck)
  182.   ;;Look for duplicates in list
  183.   (setq templist ticklist)
  184.   (while (setq tickcheck (car templist))
  185.     (if (and
  186.           (< (distance (car tick) (car tickcheck)) mintickseparation)
  187.           (< (abs (- (cadr tick) (cadr tickcheck))) mintickangulardif)
  188.         ) ;_ end of and
  189.       (setq
  190.         dupfound
  191.                  T
  192.         templist
  193.                  nil
  194.       ) ;_ end of setq
  195.       (setq templist (cdr templist))
  196.     ) ;_ end of if
  197.   ) ;_ end of while
  198.   (if (not dupfound)
  199.     (cons tick ticklist)
  200.     ticklist
  201.   ) ;_ end of if
  202. ) ;_ end of defun
  203.  
  204.  ;|&#29581;isual LISP?Format Options?
  205. (120 2 1 2 T "end of " 90 9 0 0 0 nil T nil T)
  206. ;*** DO NOT add text below the comment! ***|;
  207.  
I just want to add bliock at one endpoint

kpblc

  • Bull Frog
  • Posts: 396
There is one question: how will you get point where block should be inserted?
Sorry for my English.

meja

  • Newt
  • Posts: 47
There is one question: how will you get point where block should be inserted?
you should read this
Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (setvar "cmdecho" 0)
  3.   (setq osmode_bak (getvar "osmode"))
  4.   (setvar "osmode" 0)
  5.   (setq kk (entget (car (entsel))))
  6.   (setq kk_name (cdr (assoc 2 kk)))
  7.  
  8.   (setq pt1 (getpoint "\n&#31532;&#19968;&#28857;"))
  9.   (setq pt2 (getcorner pt1 "\n&#31532;&#20108;&#28857;"))
  10.   (setq ss (ssget "c" pt1 pt2))
  11.   (setq pt1x (car pt1)
  12.         pt1y (cadr pt1)
  13.         pt2x (car pt2)
  14.         pt2y (cadr pt2)
  15.  
  16.   )
  17.   (setq
  18.     ptx_max (max pt1x pt2x)
  19.     ptx_min (min pt1x pt2x)
  20.     pty_max (max pt1y pt2y)
  21.     pty_min (min pt1y pt2y)
  22.   )
  23.   (setq n 0)
  24.   (repeat (sslength ss)
  25.     (setq ss1 (ssname ss n))
  26.     (setq ss1_type (entget ss1))
  27.     (setq ss_q (cdr (assoc 10 ss1_type)))
  28.     (setq ss_z (cdr (assoc 11 ss1_type)))
  29.     (setq ss_qx (car ss_q)
  30.           ss_qy (cadr ss_q)
  31.     )
  32.     (if (and (and (> ss_qx ptx_min) (< ss_qx ptx_max))
  33.              (and (> ss_qy pty_min) (< ss_qy pty_max))
  34.         )
  35.       (fal_1)
  36.       (fal_2)
  37.     )
  38.     (setq n (+ 1 n))
  39.  
  40.   )
  41.   (setvar "cmdecho" 1)
  42.   (setvar "osmode" osmode_bak)
  43.   (prin1)
  44. )
  45.  
  46. (defun fal_1 ()
  47.   (command "INSERT" kk_name ss_q "" "" "")
  48. )
  49. (defun fal_2 ()
  50.   (command "INSERT" kk_name ss_z "" "" "")
  51. )
  52.  
  53.  
  54.  

kpblc

  • Bull Frog
  • Posts: 396
ssget function with "_C" option will works only in one case: both points are on screen. If this condition is met then you can use smth like this:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:test (/ adoc pt1 pt2 selset name)
  3.   (if (and (= (type (setq pt1 (vl-catch-all-apply (function (lambda () (getpoint "\nStart point <Cancel> : "))))))
  4.               'list
  5.               ) ;_ end of =
  6.            pt1
  7.            (= (type
  8.                 (setq pt2 (vl-catch-all-apply (function (lambda () (getcorner pt1 "\nEnd point <Cancel> : ")))))
  9.                 ) ;_ end of type
  10.               'list
  11.               ) ;_ end of =
  12.            pt2
  13.            (= (type (setq selset (vl-catch-all-apply
  14.                                    (function
  15.                                      (lambda ()
  16.                                        (ssget "_C" pt1 pt2 '((0 . "*LINE,ARC")))
  17.                                        ) ;_ end of lambda
  18.                                      ) ;_ end of function
  19.                                    ) ;_ end of vl-catch-all-apply
  20.                           ) ;_ end of setq
  21.                     ) ;_ end of type
  22.               'pickset
  23.               ) ;_ end of =
  24.            (= (type (setq name (vl-catch-all-apply
  25.                                  (function
  26.                                    (lambda ()
  27.                                      (getstring "\nEnter name of block to insert <Cancel> : " t)
  28.                                      ) ;_ end of lambda
  29.                                    ) ;_ end of function
  30.                                  ) ;_ end of vl-catch-all-apply
  31.                           ) ;_ end of setq
  32.                     ) ;_ end of type
  33.               'str
  34.               ) ;_ end of =
  35.            ) ;_ end of and
  36.     (if (tblobjname "block" name)
  37.       (progn
  38.         (setq pt1 (mapcar
  39.                     (function
  40.                       (lambda (a b) (* 0.5 (+ a b)))
  41.                       ) ;_ end of function
  42.                     pt1
  43.                     pt2
  44.                     ) ;_ end of mapcar
  45.               ) ;_ end of setq
  46.         (foreach ent (vl-remove-if (function (lambda (x)
  47.                                                (and (vlax-property-available-p x 'closed)
  48.                                                     (equal (vla-get-closed x) :vlax-true)
  49.                                                     ) ;_ end of and
  50.                                                ) ;_ end of lambda
  51.                                              ) ;_ end of function
  52.                                    (mapcar (function vlax-ename->vla-object)
  53.                                            ((lambda (/ tab item)
  54.                                               (repeat (setq tab  nil
  55.                                                             item (sslength selset)
  56.                                                             ) ;_ end setq
  57.                                                 (setq tab (cons (ssname selset (setq item (1- item))) tab))
  58.                                                 ) ;_ end of repeat
  59.                                               ) ;_ end of lambda
  60.                                             )
  61.                                            ) ;_ end of mapcar
  62.                                    ) ;_ end of vl-remove-if
  63.           (vla-insertblock (vla-get-modelspace adoc)
  64.                            (vlax-3d-point (car (vl-sort (list (vlax-curve-getstartpoint ent)
  65.                                                               (vlax-curve-getendpoint ent)
  66.                                                               ) ;_ end of list
  67.                                                         (function
  68.                                                           (lambda (a b)
  69.                                                             (< (distance a pt1) (distance b pt1))
  70.                                                             ) ;_ end of lambda
  71.                                                           ) ;_ end of function
  72.                                                         ) ;_ end of vl-sort
  73.                                                ) ;_ end of car
  74.                                           ) ;_ end of vlax-3d-point
  75.                            name
  76.                            1.
  77.                            1.
  78.                            1.
  79.                            0.
  80.                            ) ;_ end of vla-InsertBlock
  81.           ) ;_ end of foreach
  82.         ) ;_ end of progn
  83.       (princ (strcat "\nThere is no block definition named \"" name "\""))
  84.       ) ;_ end of if
  85.     ) ;_ end of if
  86.   (vla-endundomark adoc)
  87.   (princ)
  88.   ) ;_ end of defun
Sorry for my English.

DuanJinHui

  • Guest
ssget function with "_C" option will works only in one case: both points are on screen. If this condition is met then you can use smth like this:


Hi kp, This is your code ?
http://www.cadtutor.net/forum/showthread.php?92246-error-ActiveX-Server-returned-the-error-unknown-name-Explode
ActiveX explode method does not apply to an ACAD_PROXY_ENTITY entity type
« Last Edit: May 21, 2015, 08:04:48 AM by DuanJinHui »

kpblc

  • Bull Frog
  • Posts: 396
Looks like mine. But at this topic i didn't use any "explode" function.
Sorry for my English.

DuanJinHui

  • Guest
Looks like mine. But at this topic i didn't use any "explode" function.

 kp, Thank you for reply, But,  that code is doing what ?

kpblc

  • Bull Frog
  • Posts: 396
Tries to explode all proxy objects in file. Unsuccessful^ this task requires ObjectARX or .NET
Sorry for my English.

meja

  • Newt
  • Posts: 47
ssget function with "_C" option will works only in one case: both points are on screen. If this condition is met then you can use smth like this:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:test (/ adoc pt1 pt2 selset name)
  3.   (if (and (= (type (setq pt1 (vl-catch-all-apply (function (lambda () (getpoint "\nStart point <Cancel> : "))))))
  4.               'list
  5.               ) ;_ end of =
  6.            pt1
  7.            (= (type
  8.                 (setq pt2 (vl-catch-all-apply (function (lambda () (getcorner pt1 "\nEnd point <Cancel> : ")))))
  9.                 ) ;_ end of type
  10.               'list
  11.               ) ;_ end of =
  12.            pt2
  13.            (= (type (setq selset (vl-catch-all-apply
  14.                                    (function
  15.                                      (lambda ()
  16.                                        (ssget "_C" pt1 pt2 '((0 . "*LINE,ARC")))
  17.                                        ) ;_ end of lambda
  18.                                      ) ;_ end of function
  19.                                    ) ;_ end of vl-catch-all-apply
  20.                           ) ;_ end of setq
  21.                     ) ;_ end of type
  22.               'pickset
  23.               ) ;_ end of =
  24.            (= (type (setq name (vl-catch-all-apply
  25.                                  (function
  26.                                    (lambda ()
  27.                                      (getstring "\nEnter name of block to insert <Cancel> : " t)
  28.                                      ) ;_ end of lambda
  29.                                    ) ;_ end of function
  30.                                  ) ;_ end of vl-catch-all-apply
  31.                           ) ;_ end of setq
  32.                     ) ;_ end of type
  33.               'str
  34.               ) ;_ end of =
  35.            ) ;_ end of and
  36.     (if (tblobjname "block" name)
  37.       (progn
  38.         (setq pt1 (mapcar
  39.                     (function
  40.                       (lambda (a b) (* 0.5 (+ a b)))
  41.                       ) ;_ end of function
  42.                     pt1
  43.                     pt2
  44.                     ) ;_ end of mapcar
  45.               ) ;_ end of setq
  46.         (foreach ent (vl-remove-if (function (lambda (x)
  47.                                                (and (vlax-property-available-p x 'closed)
  48.                                                     (equal (vla-get-closed x) :vlax-true)
  49.                                                     ) ;_ end of and
  50.                                                ) ;_ end of lambda
  51.                                              ) ;_ end of function
  52.                                    (mapcar (function vlax-ename->vla-object)
  53.                                            ((lambda (/ tab item)
  54.                                               (repeat (setq tab  nil
  55.                                                             item (sslength selset)
  56.                                                             ) ;_ end setq
  57.                                                 (setq tab (cons (ssname selset (setq item (1- item))) tab))
  58.                                                 ) ;_ end of repeat
  59.                                               ) ;_ end of lambda
  60.                                             )
  61.                                            ) ;_ end of mapcar
  62.                                    ) ;_ end of vl-remove-if
  63.           (vla-insertblock (vla-get-modelspace adoc)
  64.                            (vlax-3d-point (car (vl-sort (list (vlax-curve-getstartpoint ent)
  65.                                                               (vlax-curve-getendpoint ent)
  66.                                                               ) ;_ end of list
  67.                                                         (function
  68.                                                           (lambda (a b)
  69.                                                             (< (distance a pt1) (distance b pt1))
  70.                                                             ) ;_ end of lambda
  71.                                                           ) ;_ end of function
  72.                                                         ) ;_ end of vl-sort
  73.                                                ) ;_ end of car
  74.                                           ) ;_ end of vlax-3d-point
  75.                            name
  76.                            1.
  77.                            1.
  78.                            1.
  79.                            0.
  80.                            ) ;_ end of vla-InsertBlock
  81.           ) ;_ end of foreach
  82.         ) ;_ end of progn
  83.       (princ (strcat "\nThere is no block definition named \"" name "\""))
  84.       ) ;_ end of if
  85.     ) ;_ end of if
  86.   (vla-endundomark adoc)
  87.   (princ)
  88.   ) ;_ end of defun

Thx buddy,this code can do with lwpolyline!!!HOW CAN YOU DO THAT?
« Last Edit: May 21, 2015, 09:33:59 AM by meja »

ChrisCarlson

  • Guest
ssget function with "_C" option will works only in one case: both points are on screen. If this condition is met then you can use smth like this:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:test (/ adoc pt1 pt2 selset name)
  3.   (if (and (= (type (setq pt1 (vl-catch-all-apply (function (lambda () (getpoint "\nStart point <Cancel> : "))))))
  4.               'list
  5.               ) ;_ end of =
  6.            pt1
  7.            (= (type
  8.                 (setq pt2 (vl-catch-all-apply (function (lambda () (getcorner pt1 "\nEnd point <Cancel> : ")))))
  9.                 ) ;_ end of type
  10.               'list
  11.               ) ;_ end of =
  12.            pt2
  13.            (= (type (setq selset (vl-catch-all-apply
  14.                                    (function
  15.                                      (lambda ()
  16.                                        (ssget "_C" pt1 pt2 '((0 . "*LINE,ARC")))
  17.                                        ) ;_ end of lambda
  18.                                      ) ;_ end of function
  19.                                    ) ;_ end of vl-catch-all-apply
  20.                           ) ;_ end of setq
  21.                     ) ;_ end of type
  22.               'pickset
  23.               ) ;_ end of =
  24.            (= (type (setq name (vl-catch-all-apply
  25.                                  (function
  26.                                    (lambda ()
  27.                                      (getstring "\nEnter name of block to insert <Cancel> : " t)
  28.                                      ) ;_ end of lambda
  29.                                    ) ;_ end of function
  30.                                  ) ;_ end of vl-catch-all-apply
  31.                           ) ;_ end of setq
  32.                     ) ;_ end of type
  33.               'str
  34.               ) ;_ end of =
  35.            ) ;_ end of and
  36.     (if (tblobjname "block" name)
  37.       (progn
  38.         (setq pt1 (mapcar
  39.                     (function
  40.                       (lambda (a b) (* 0.5 (+ a b)))
  41.                       ) ;_ end of function
  42.                     pt1
  43.                     pt2
  44.                     ) ;_ end of mapcar
  45.               ) ;_ end of setq
  46.         (foreach ent (vl-remove-if (function (lambda (x)
  47.                                                (and (vlax-property-available-p x 'closed)
  48.                                                     (equal (vla-get-closed x) :vlax-true)
  49.                                                     ) ;_ end of and
  50.                                                ) ;_ end of lambda
  51.                                              ) ;_ end of function
  52.                                    (mapcar (function vlax-ename->vla-object)
  53.                                            ((lambda (/ tab item)
  54.                                               (repeat (setq tab  nil
  55.                                                             item (sslength selset)
  56.                                                             ) ;_ end setq
  57.                                                 (setq tab (cons (ssname selset (setq item (1- item))) tab))
  58.                                                 ) ;_ end of repeat
  59.                                               ) ;_ end of lambda
  60.                                             )
  61.                                            ) ;_ end of mapcar
  62.                                    ) ;_ end of vl-remove-if
  63.           (vla-insertblock (vla-get-modelspace adoc)
  64.                            (vlax-3d-point (car (vl-sort (list (vlax-curve-getstartpoint ent)
  65.                                                               (vlax-curve-getendpoint ent)
  66.                                                               ) ;_ end of list
  67.                                                         (function
  68.                                                           (lambda (a b)
  69.                                                             (< (distance a pt1) (distance b pt1))
  70.                                                             ) ;_ end of lambda
  71.                                                           ) ;_ end of function
  72.                                                         ) ;_ end of vl-sort
  73.                                                ) ;_ end of car
  74.                                           ) ;_ end of vlax-3d-point
  75.                            name
  76.                            1.
  77.                            1.
  78.                            1.
  79.                            0.
  80.                            ) ;_ end of vla-InsertBlock
  81.           ) ;_ end of foreach
  82.         ) ;_ end of progn
  83.       (princ (strcat "\nThere is no block definition named \"" name "\""))
  84.       ) ;_ end of if
  85.     ) ;_ end of if
  86.   (vla-endundomark adoc)
  87.   (princ)
  88.   ) ;_ end of defun

Thx buddy,I hope this code can do with lwpolyline!!!CAN YOU DO THAT?

Please take a look at line 18

meja

  • Newt
  • Posts: 47
ps:CAN CODE DO WITH A LEADER?

ChrisCarlson

  • Guest
You want to add a block at the end of a leader?

Did you solve the issue of modifying the routine to include lwpolyline?

kpblc

  • Bull Frog
  • Posts: 396
ps:CAN CODE DO WITH A LEADER?
LEADER and MLEADER objects requires different solution - you have to change Annotation property. I never did this: changing annotation could change control points of leader object.
P.S. ssget filter "*LINE,ARC" make available to select LINE, LWPOLYLINE, POLYLINE, 3DPOLYLINE, SPLINE, ARC objects. Next removes closed polylines and splines.
Sorry for my English.

meja

  • Newt
  • Posts: 47
Just lwpline leader