Modify LISP to use LWPOLYLINES

Modify LISP to use LWPOLYLINES

jtm2020hyo
Collaborator Collaborator
2,439 Views
29 Replies
Message 1 of 30

Modify LISP to use LWPOLYLINES

jtm2020hyo
Collaborator
Collaborator

I need change this lisp to use LWPOLYLINES instead of ARC/LINES.

 

this lisp INSert  Aligned BLOCKs in ARCs/LINEs midpoints.

 

I tried to change :

           t
         )
         (progn (prompt "\n Select lines ...")
                (setq ss (ssget '((0 . "LINE"))))
         )
    )

to :

 

           t
         )
         (progn (prompt "\n Select lines ...")
                (setq ss (ssget '((0 . "LWPOLYLINE"))))
         )
    )

but it did not work.

 

 

Original lisp code :

 

(defun c:Mins (/ name ss i e p1 p2)
  (if
    (and (or (/= (setq name (getstring t "\n Specify Block name :")) "")
             (/= name nil)
         )
         (if (not (tblsearch "BLOCK" name))
           (progn
             (alert " name of Block is not found !!")
             nil
           )
           t
         )
         (progn (prompt "\n Select lines ...")
                (setq ss (ssget '((0 . "LINE"))))
         )
    )
     (repeat (setq i (sslength ss))
       (setq e (entget (ssname ss (setq i (1- i)))))
       (entmakex
         (list '(0 . "INSERT")
               (cons 10
                     (mapcar (function (lambda (q p) (/ (+ q p) 2.)))
                             (setq p1 (cdr (assoc 10 e)))
                             (setq p2 (cdr (assoc 11 e)))
                     )
               )
               (cons 2 name)
               (cons 50 (angle p1 p2))
               '(41 . 1.0)
               '(42 . 1.0)
               '(43 . 1.0)
         )
       )
     )
     (princ)
  )
  (princ)
)

 

 

 

0 Likes
Accepted solutions (1)
2,440 Views
29 Replies
Replies (29)
Message 21 of 30

pbejse
Mentor
Mentor

@Anonymous wrote:

 Qustion, is there any way to modify your pld.lisp to add arc's that can follow the contour of a line. I work with cnc's and they are not to keen on loading an excessive amount of lines. If i diet the lines to much with out arc's it will leave hard angles that will have to be hand sanded off. I left examples in the attachment.


Are you referring to the code at post#4? and can you post a dwg file instead of DXF format?

I made a simple and quick adjustment on the code in the very first post, thinking that's all you're asking for.

 

0 Likes
Message 22 of 30

Anonymous
Not applicable

 


@pbejsewrote:

@Anonymouswrote:

 Qustion, is there any way to modify your pld.lisp to add arc's that can follow the contour of a line. I work with cnc's and they are not to keen on loading an excessive amount of lines. If i diet the lines to much with out arc's it will leave hard angles that will have to be hand sanded off. I left examples in the attachment.


Are you referring to the code at post#4? and can you post a dwg file instead of DXF format?

I made a simple and quick adjustment on the code in the very first post, thinking that's all you're asking for.

 


I was referring to this .lsp in attachments and I attached a dwg for you as well.

Message 23 of 30

Kent1Cooper
Consultant
Consultant

Since the wording "your  pld.lisp" refers to me....

 

I can't picture a way to alter PLDiet to do what you want.  It's really an entirely different kind of adjustment from what the routine is designed to do.  It would have to be made to analyze multiple [how many should it look at?] sequential vertices in a Polyline to decide whether or how many of them fall close enough to lying along some as-yet-undefined arc-shaped path that the intervening line segments should be converted to an arc segment.  Even if it could determine that, what it would have to do to the Polyline would be hugely more complex than the PEDIT-Edit-Straighten operation that it currently uses.  If something I haven't though of yet occurs to me, I'll come back, but I don't know....

 

Can you use PEDIT's Spline-curve option on the curve-approximating parts of the too-kinked PLD result?

Kent Cooper, AIA
Message 24 of 30

Anonymous
Not applicable

@Kent1Cooperwrote:

Since the wording "your  pld.lisp" refers to me....

 

I can't picture a way to alter PLDiet to do what you want.  It's really an entirely different kind of adjustment from what the routine is designed to do.  It would have to be made to analyze multiple [how many should it look at?] sequential vertices in a Polyline to decide whether or how many of them fall close enough to lying along some as-yet-undefined arc-shaped path that the intervening line segments should be converted to an arc segment.  Even if it could determine that, what it would have to do to the Polyline would be hugely more complex than the PEDIT-Edit-Straighten operation that it currently uses.  If something I haven't though of yet occurs to me, I'll come back, but I don't know....

 

Can you use PEDIT's Spline-curve option on the curve-approximating parts of the too-kinked PLD result?


sadly splines can not be read by the neither of the cnc's main operating systems. Only lines , polylines, arc's, and circles. if i spline it then explode it and run a boundary is leaves me worse off than i started. I appreciate the info regardless.   

Message 25 of 30

pbejse
Mentor
Mentor

@Kent1Cooper wrote:

Since the wording "your  pld.lisp" refers to me....

 


Oops my bad. I did not notice it before but the user asking for the pld mod was not the OP [  juanj67m ]

 

My apologies Kent.

 

Message 26 of 30

jtm2020hyo
Collaborator
Collaborator

 

Here's an updated version that allows multiple object selection.  [Lightly tested]



Kent Cooper, AIA
EXPERT ELITE MEMBER

Add tags
 MarkMidPoints.lsp ‏15 KB

 

this lisp work pretty well. but it can be modified to ignore zero-lenght polylines or lines or points?

 

 

0 Likes
Message 27 of 30

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:

.... 

this lisp work pretty well. but it can be modified to ignore zero-lenght polylines or lines or points?


It already ignores [i.e. doesn't allow selection of] Points.  For zero-length objects of all the types you can  select in it, try adding these lines [untested]:

 

;;;;

         pathextr (cdr (assoc 210 pathdata))
        ); setq

        (if (> (vlax-curve-getDistAtParam path (vlax-curve-getEndParam path)) 0)

          (progn
        (if ; set UCS to match object only under certain circumstances
          (or ; look at entity types other than 3D Polylines and 3D Splines

;;;;

;;;;

          ); cond
        ); repeat

          ); progn

        ); if
        (if ucschanged (command "_.ucs" "_prev"))
        (setq ucschanged nil); eliminate UCS reset in *error* since routine did it already

;;;;

 

[And if you like to be consistent about indentations, indent all the lines between those added ones by four more spaces.]

Kent Cooper, AIA
Message 28 of 30

jtm2020hyo
Collaborator
Collaborator
It already ignores [i.e. doesn't allow selection of] Points.  For zero-length objects of all the types you can  select in it, try adding these lines [untested]:

code is great and ignore zero-lenght *lines . but i have problems with polylines with zero-lenght segment. I tried EXPLODE and purge them and delete QSELECT-<less selected , but i need do this for 6 or 7 times each time and i need do this each time in 1000 polylines.

 

...then if code already ignore zero-lenght polylines, Can be added a option to ignore a minimal of size lenght ?... like "Minimun size to insert (default=0) : 0.01" (for example.) 

 

0 Likes
Message 29 of 30

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:

... i have problems with polylines with zero-lenght segment. .... 


OVERKILL will get rid of those for you.  Make sure the "Optimize segments within polylines" option is checked.

Kent Cooper, AIA
Message 30 of 30

jtm2020hyo
Collaborator
Collaborator
OVERKILL will get rid of those for you.  Make sure the "Optimize segments within polylines" option is checked.



Kent Cooper, AIA
EXPERT ELITE MEMBER

thanks for help . you are the best.

 

 

0 Likes