Author Topic: break fence  (Read 922 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 720
break fence
« on: November 27, 2023, 09:11:45 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun :INTERS-OBJ1-OBJ2-MODE   (o1 o2 mode / l r)
  2.    (if(setq l (vlax-invoke o1 'intersectwith o2 mode))
  3.       (repeat (/ (length l) 3) (setq r (cons (list (car l) (cadr l) (caddr l)) r) l (cdddr l) ) )
  4.    )
  5.    (reverse r)
  6. )
  7.  
  8.  
  9. (defun :CRV-LENGTH (curve-object)
  10.    (vlax-curve-getDistAtParam   curve-object (vlax-curve-getEndParam curve-object))
  11. )
  12.  
  13. (defun :CRV-MEASURE-CENTER   (   crv-obj delta
  14.                                 /
  15.                                 crv-len n-elm r-v-lst start-dst x-dst x-len x-v
  16.                            )
  17.    (setq crv-len     (:CRV-LENGTH crv-obj)
  18.          n-elm       (fix (/ crv-len delta ) )
  19.          x-len       (* n-elm delta)
  20.          start-dst   (/ (- crv-len x-len) 2.0)
  21.          x-dst start-dst
  22.    )
  23.    (while (< x-dst crv-len)
  24.       (setq x-v       (vlax-curve-getpointatdist crv-obj x-dst)
  25.             r-v-lst    (cons x-v r-v-lst  )
  26.             x-dst    (+ x-dst delta)
  27.       )
  28.    )
  29.    (reverse r-v-lst)
  30. )
  31.  
  32.  
  33. (defun C:BREAK-FENCE (   /
  34.                          crv-en crv-es crv-obj brk-ss brk-ss-obj-lst
  35.                          crv-length fence-delta fence-v-lst int-lst ssa x-obj
  36.                      )
  37.    (xdrx-begin)
  38.    (and
  39.       (sssetfirst nil nil )
  40.       (xdrx-setmark)
  41.       (setq crv-es  (xdrx-entsel "\nselect the curve to break with intersecting objects <exit> : " '( (0 . "*line,arc,ellipse,spline") ) ) )
  42.       (setq crv-en  (car crv-es) )
  43.       (progn (redraw crv-en 3) t)
  44.       (setq crv-obj (vlax-ename->vla-object crv-en) )
  45.       (setq crv-length (:CRV-LENGTH   crv-obj) )
  46.       (setq fence-delta (/ crv-length 20.0) ) ;  let the user to decide ...
  47.       (setq fence-v-lst (:CRV-MEASURE-CENTER crv-obj  fence-delta) )
  48.       (setq brk-ss (ssget "f" fence-v-lst) )
  49.       (setq brk-ss (ssdel crv-en brk-ss) )
  50.       (setq brk-ss-obj-lst (mapcar 'vlax-ename->vla-object (xdrx-pickset->ents brk-ss) ) )
  51.       (setq int-lst (mapcar   '(lambda (x-obj) (:INTERS-OBJ1-OBJ2-MODE crv-obj x-obj acExtendNone) ) brk-ss-obj-lst ) )
  52.       (setq int-lst (apply 'append int-lst) )
  53.       (xdrx-curve-getsplitcurves crv-en int-lst )
  54.       (setq ssa (xdrx-getss) )
  55.       (setq ssa (ssadd crv-en ssa) )
  56.       (sssetfirst nil ssa) (ssget "_I")
  57.    )
  58.    (xdrx-end)
  59.    (if ssa ssa (princ) )
  60. )
  61.  
  62. (defun C:BF ()(C:BREAK-FENCE))



https://drive.google.com/file/d/1OWrF_6Jg6YjT3FbDqhCT-vLvYfuXP3MJ/view?usp=sharing


This is to show the new possibilities introduced by xdrx-curve-getsplitcurves

and it could be helpful if mr. XD will improve the functionality of this routine
by using the functions of the XDRX-... package as much as possible
« Last Edit: November 27, 2023, 11:47:23 AM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: break fence
« Reply #1 on: November 27, 2023, 11:19:52 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:FENCE-BREAK (   /
  2.                          brk-ss brk-ss-obj-lst crv-en crv-es crv-length
  3.                          crv-obj fence-delta fence-v-lst obj-int-lst ssa x-obj
  4.                      )
  5.    (xdrx-begin)
  6.    (and
  7.       (sssetfirst nil nil )
  8.       (xdrx-setmark)
  9.       (setq crv-es  (xdrx-entsel "\nselect the breaking curve <exit> : " '( (0 . "*line,arc,ellipse,spline") ) ) )
  10.       (setq crv-en  (car crv-es) )
  11.       (progn (redraw crv-en 3) t)
  12.       (setq crv-obj (vlax-ename->vla-object crv-en) )
  13.       (setq crv-length (:CRV-LENGTH   crv-obj) )
  14.       (setq fence-delta (/ crv-length 20.0) ) ;  let the user to decide ...
  15.       (setq fence-v-lst (:CRV-MEASURE-CENTER crv-obj  fence-delta) )
  16.       (setq brk-ss (ssget "f" fence-v-lst) )
  17.       (setq brk-ss (ssdel crv-en brk-ss) )
  18.       (setq brk-ss-obj-lst (mapcar 'vlax-ename->vla-object (xdrx-pickset->ents brk-ss) ) )
  19.       (setq obj-int-lst (mapcar '(lambda (x-obj) (cons (vlax-vla-object->ename x-obj) (:INTERS-OBJ1-OBJ2-MODE crv-obj x-obj acExtendNone) ) ) brk-ss-obj-lst ) )
  20.       (foreach oil obj-int-lst
  21.          (xdrx-curve-getsplitcurves (car oil) (cdr oil) )
  22.       )
  23.       (setq ssa (xdrx-getss) )
  24.       (sssetfirst nil ssa) (ssget "_I")
  25.    )
  26.    (xdrx-end)
  27.    (if ssa ssa (princ) )
  28. )
  29.  
  30. (defun C:FB ()(C:FENCE-BREAK) )
  31.  

while in this routine, the selected curve breaks everything it encounters

https://drive.google.com/file/d/1RsY--YTqvqrZ3tdeAUB84gnRBhaBXtpz/view?usp=sharing
« Last Edit: November 27, 2023, 11:47:04 AM by domenicomaria »

xdcad

  • Bull Frog
  • Posts: 424
Re: break fence
« Reply #2 on: November 27, 2023, 06:53:00 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:FENCE-BREAK (   /
  2.                          brk-ss brk-ss-obj-lst crv-en crv-es crv-length
  3.                          crv-obj fence-delta fence-v-lst obj-int-lst ssa x-obj
  4.                      )
  5.    (xdrx-begin)
  6. .....
  7.  

while in this routine, the selected curve breaks everything it encounters

https://drive.google.com/file/d/1RsY--YTqvqrZ3tdeAUB84gnRBhaBXtpz/view?usp=sharing

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2. ;|
  3. xdrx-curve-getsamplepoints
  4. Take sample points or bisection points on the curve, which can be the entire curve, or based on the starting point or sample points between the starting parameter values.
  5. (xdrx-curve-getsamplepoints curve)
  6. (xdrx-curve-getsamplepoints curve integer)
  7. (xdrx-curve-getsamplepoints curve real)
  8. (xdrx-curve-getsamplepoints curve [spt ept] [integer or real number] [t])
  9. (xdrx-curve-getsamplepoints curve [spram epram] [integer or real number] [t])
  10.  
  11. parameter:
  12. 1. The first real number is the distance, the second real number is the starting parameter,
  13.    and the third real number is the ending parameter.
  14. 2. If given an integer, find the divide points
  15. 3. If T is given, the parameter value of the sample point is returned instead of the point.
  16. 4. If you do not give a real number approxEps parameter, then the pickbox height will be used
  17.    as the approxEps when simulating the curve by default.
  18. |;
  19.   (if (and (setq e (car (xdrx-entsel
  20.                           "\nselect the breaking curve <exit> : "
  21.                           '((0 . "*line,arc,ellipse,spline"))
  22.                         )
  23.                    )
  24.            )
  25.            (setq pts (xdrx-curve-getsamplepoints e))
  26.            (setq ss (ssget "f" pts '((0 . "*line,arc,ellipse,spline"))))
  27.            (setq ints (xdrx-entity-intersectwith e ss))
  28.       )
  29.     (progn
  30.       (xdrx-begin)
  31.       (xdrx-curve-getsplitcurves e ints)
  32.       (xdrx-end)
  33.     )
  34.   )
  35.   (princ)
  36. )
« Last Edit: November 27, 2023, 06:58:56 PM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

xdcad

  • Bull Frog
  • Posts: 424
Re: break fence
« Reply #3 on: November 27, 2023, 06:57:36 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun :INTERS-OBJ1-OBJ2-MODE   (o1 o2 mode / l r)
  2.    (if(setq l (vlax-invoke o1 'intersectwith o2 mode))
  3.  .......
  4.  
  5.  
https://drive.google.com/file/d/1OWrF_6Jg6YjT3FbDqhCT-vLvYfuXP3MJ/view?usp=sharing


This is to show the new possibilities introduced by xdrx-curve-getsplitcurves

and it could be helpful if mr. XD will improve the functionality of this routine
by using the functions of the XDRX-... package as much as possible

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2. ;|
  3. xdrx-curve-getsamplepoints
  4. Take sample points or bisection points on the curve, which can be the entire curve, or based on the starting point or sample points between the starting parameter values.
  5. (xdrx-curve-getsamplepoints curve)
  6. (xdrx-curve-getsamplepoints curve integer)
  7. (xdrx-curve-getsamplepoints curve real)
  8. (xdrx-curve-getsamplepoints curve [spt ept] [integer or real number] [t])
  9. (xdrx-curve-getsamplepoints curve [spram epram] [integer or real number] [t])
  10.  
  11. parameter:
  12. 1. The first real number is the distance, the second real number is the starting parameter,
  13.    and the third real number is the ending parameter.
  14. 2. If given an integer, find the divide points
  15. 3. If T is given, the parameter value of the sample point is returned instead of the point.
  16. 4. If you do not give a real number approxEps parameter, then the pickbox height will be used
  17.    as the approxEps when simulating the curve by default.
  18. |;
  19.   (if (and (setq e (car (xdrx-entsel
  20.                           "\nselect the breaking curve <exit> : "
  21.                           '((0 . "*line,arc,ellipse,spline"))
  22.                         )
  23.                    )
  24.            )
  25.            (setq pts (xdrx-curve-getsamplepoints e))
  26.            (setq ss (ssget "f" pts '((0 . "*line,arc,ellipse,spline"))))
  27.  
  28.       )
  29.     (progn
  30.       (xdrx-begin)
  31.       (mapcar '(lambda (x)
  32.                  (setq ints (xdrx-entity-intersectwith x e))
  33.                  (xdrx-curve-getsplitcurves x ints)
  34.                )
  35.               (xdrx-pickset->ents ss)
  36.       )
  37.       (xdrx-end)
  38.     )
  39.   )
  40.   (princ)
  41. )
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: break fence
« Reply #4 on: November 28, 2023, 02:04:45 AM »
HI. I saw your examples, your tests...

xdrx-curve-getsamplepoints is another great function
that can also be used to redefine commands like measure and divide...
...
I'm truly impressed by the power of these features as I discover them!