Author Topic: small pieces to remove  (Read 7547 times)

0 Members and 1 Guest are viewing this topic.

dexus

  • Bull Frog
  • Posts: 211
Re: small pieces to remove
« Reply #30 on: November 24, 2023, 06:10:33 AM »
Like Ribarm used Cab's breakall, I used recently for a task, then just do a ssget and look at length of objects if short then delete.

but Cab's breakall will break all curves at all intersections!

So after that the curves are all broken !

And then if you join them again,
in each curve there will be some more vertices
where there were intersections...!

Or is what I'm saying incorrect?
You can use Purge-pline from gile to remove the unnecessary vertices again.
https://www.theswamp.org/index.php?topic=19865.msg244892#msg244892

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: small pieces to remove
« Reply #31 on: November 24, 2023, 08:18:41 AM »
You can use Purge-pline from gile to remove the unnecessary vertices again.
https://www.theswamp.org/index.php?topic=19865.msg244892#msg244892
ok, but the best thing, however,
is not to break the curves when it is not necessary ...

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: small pieces to remove
« Reply #32 on: November 24, 2023, 10:47:46 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:BREAK-ON-PT ( / x-en x-es x-pt)
  2.    (and
  3.       (setq x-es (xdrx-entsel "\nselect the curve to break <exit> : " '((0 . "*line,arc,ellipse"))))
  4.       (setq x-en (car x-es) )
  5.       (setq x-pt (getpoint "\nbreak point <exit> : ") )
  6.       (xdrx-curve-getsplitcurves x-en (list x-pt) )
  7.    )
  8. )
  9. (defun C:BP () (C:BREAK-ON-PT) )

an alternative (that could be easily implemented) to (command "break" ...)
« Last Edit: November 24, 2023, 10:52:53 AM by domenicomaria »

xdcad

  • Swamp Rat
  • Posts: 505
Re: small pieces to remove
« Reply #33 on: November 24, 2023, 07:03:48 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:BREAK-ON-PT ( / x-en x-es x-pt)
  2.    (and
  3.       (setq x-es (xdrx-entsel "\nselect the curve to break <exit> : " '((0 . "*line,arc,ellipse"))))
  4.       (setq x-en (car x-es) )
  5.       (setq x-pt (getpoint "\nbreak point <exit> : ") )
  6.       (xdrx-curve-getsplitcurves x-en (list x-pt) )
  7.    )
  8. )
  9. (defun C:BP () (C:BREAK-ON-PT) )

an alternative (that could be easily implemented) to (command "break" ...)

For the situation of processing a curve in the loop

1. If you only call xdrx-curve-getsplitcurves, the curve itself will be interrupted at the intersection, as shown below:



2. Calling xdrx-curve-getsplitcurves will generate a processed selection set, in which we delete the shortest line that meets the conditions, and then join the remaining disconnected lines, as shown below, and the problem will be solved.



Test code:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (and (setq ss (xdrx-ssget
  3.                       "\nSelect Curve<Quit>:"
  4.                       '((0 . "*line,arc,ellipse"))
  5.                     )
  6.            )
  7.            (setq e (xdrx-entsel
  8.                      "\nPick Test Curve<Quit>:"
  9.                      '((0 . "*line,arc,ellipse"))
  10.                    )
  11.            )
  12.       )
  13.     (progn
  14.       (setq e  (car e)
  15.             ss (ssdel e ss)
  16.       )
  17.       (if (setq ints (xdrx-entity-intersectwith e ss))
  18.         (progn
  19.           (setq ss1 (xdrx-curve-getsplitcurves e ints))
  20.           (mapcar '(lambda (x)
  21.                      (if (< (xdrx-getpropertyvalue x "length") 200.0);;Erease Short Line
  22.                        (xdrx-entity-delete x)
  23.                      )
  24.                    )
  25.                   (xdrx-pickset->ents ss1)
  26.           )
  27.           (xdrx-curve-join ss1);;Join the interrupted curves together again
  28.         )
  29.       )
  30.     )
  31.   )
  32.   (princ)
  33. )

The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

xdcad

  • Swamp Rat
  • Posts: 505
Re: small pieces to remove
« Reply #34 on: November 24, 2023, 07:09:28 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:BREAK-ON-PT ( / x-en x-es x-pt)
  2.    (and
  3.       (setq x-es (xdrx-entsel "\nselect the curve to break <exit> : " '((0 . "*line,arc,ellipse"))))
  4.       (setq x-en (car x-es) )
  5.       (setq x-pt (getpoint "\nbreak point <exit> : ") )
  6.       (xdrx-curve-getsplitcurves x-en (list x-pt) )
  7.    )
  8. )
  9. (defun C:BP () (C:BREAK-ON-PT) )

an alternative (that could be easily implemented) to (command "break" ...)

This is the code used by AUTOCAD's own internal BREAK command.
It is just the process of translating ARX using LISP.
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8786
  • AKA Daniel
Re: small pieces to remove
« Reply #35 on: November 24, 2023, 07:18:06 PM »
Maybe xdrx-curve-getsplitcurves can return lists to be used in entmake instead of clobbering the original

xdcad

  • Swamp Rat
  • Posts: 505
Re: small pieces to remove
« Reply #36 on: November 24, 2023, 07:35:28 PM »
Maybe xdrx-curve-getsplitcurves can return lists to be used in entmake instead of clobbering the original

thanks.....

I don't quite understand what you mean.

(xdrx-curve-getsplitcurves e pnts)

returned is the selection set of newly generated entities after the curve is interrupted by points.

What do you mean by destroying the original entmake List?
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8786
  • AKA Daniel
Re: small pieces to remove
« Reply #37 on: November 24, 2023, 08:01:02 PM »
Never mind, I thought you were modifying the original

xdcad

  • Swamp Rat
  • Posts: 505
Re: small pieces to remove
« Reply #38 on: November 24, 2023, 08:11:06 PM »
Never mind, I thought you were modifying the original

thanks....


Oh, I see what you mean
What you mean is not to process the original curve, but to generate entget tables, and then let LISP generate them.

I feel like it's a little detoured,

If you want the original curve to remain unchanged, use the following before operation:

(setq after (xdrx-object-clone source))

Just generate a backup

If you donít want to change the backup curve entity name or color,linetype.....
At once:
(xdrx-object-swapid after source)
(xdrx-enitty-matchprop source after)
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8786
  • AKA Daniel
Re: small pieces to remove
« Reply #39 on: November 24, 2023, 08:24:53 PM »
IMHO , the original should not be modified, it contradicts the documentation. functions should match the ARX docs as closely as possible

- either, add the new objects to the database so they can be deleted later, or
- provide the data to generate the new objects.

Having to call (xdrx-object-swapid after source) or (xdrx-enitty-matchprop source after) seems very detoured, coming from an ARX perspective

just my opinion though

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: small pieces to remove
« Reply #40 on: November 24, 2023, 11:48:36 PM »
Maybe xdrx-curve-getsplitcurves can return lists to be used in entmake instead of clobbering the original
actually another function like xdrx-curve-getsplitcurves
could be useful by returning the informations to create (with entmake)
the pieces of curve defined by the list of intersections ...

...so the user could first check the data and then decide what to do...

... and this seems logically correct to me ...
« Last Edit: November 25, 2023, 12:03:18 AM by domenicomaria »

xdcad

  • Swamp Rat
  • Posts: 505
Re: small pieces to remove
« Reply #41 on: November 25, 2023, 12:26:59 AM »
IMHO , the original should not be modified, it contradicts the documentation. functions should match the ARX docs as closely as possible

- either, add the new objects to the database so they can be deleted later, or
- provide the data to generate the new objects.

Having to call (xdrx-object-swapid after source) or (xdrx-enitty-matchprop source after) seems very detoured, coming from an ARX perspective

just my opinion though

Thanks for the suggestion
In the next version of API, xdrx-curve-getsplitcurves will add a parameter t
will return the AcGe geometry entity list.

Code - Auto/Visual Lisp: [Select]
  1. Select object: <Entity name: 1a0f34b1dc0>
  2.  
  3. Command: (setq ints (xdrx-entity-intersectwith e ss))
  4. ((3607.04 1761.67 0.0) (3742.7 1497.1 0.0) (3647.68 1217.72 0.0))
  5.  
  6. Command: (setq ents (xdrx-curve-getsplitcurves e ints t))
  7. (<Entity name: 1a0af6cbc50> <Entity name: 1a0af6cbe70> <Entity name: 1a0af6cc0f0> <Entity name: 1a0af6cbb70>)
  8.  
  9. Command: (mapcar '(lambda(x)(xdrx-object-isa x)) ents)
  10. ("kCompositeCrv3d" "kCompositeCrv3d" "kCompositeCrv3d" "kCompositeCrv3d")
  11.  
  12. Command: (mapcar '(lambda(x)(xdrx-getpropertyvalue x "length")) ents)
  13. (861.66 306.442 301.473 312.489)
  14.  
  15. Command: (mapcar '(lambda(x)(xdrx-getpropertyvalue x "area" "length")) ents)
  16. ((59123.0 861.66) (6409.2 306.442) (5277.28 301.473) (5708.8 312.489))
  17.  
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8786
  • AKA Daniel
Re: small pieces to remove
« Reply #42 on: November 25, 2023, 02:22:29 AM »
that's so cool!  8-)

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: small pieces to remove
« Reply #43 on: November 27, 2023, 01:18:42 PM »
I've updated CAB's BreakObjects.lsp...
You can find it here :
https://www.theswamp.org/index.php?topic=57930.msg617266#msg617266

And here :
https://www.cadtutor.net/forum/files/file/51-breakobjectslsp/

And for gift there is in this attachment flashpoly.lsp that is closely connected with (c:BreakAll-nogaps)...
« Last Edit: November 28, 2023, 03:18:57 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube