Jump to content

Recommended Posts

Posted

Looking for some help here as I have the command line message "error: extra right paren on input" when I load the following lisp: -

 

(defun c:Slice3DPoly ( / _FindZOnLine ed en i p1 p2 pl sl ss tp vd vl )

   ;; A modification by Lee Mac of the code by David Bethel found here:
   ;; http://www.cadtutor.net/forum/showthread.php?62556-3D-polyline-Intersection&p=426585&viewfull=1#post426585

   (defun _FindZOnLine ( fp p1 p2 )
       (cond
           (   (or (equal p1 p2 1e-11)
                   (equal (caddr p1) (caddr p2) 1e-11)
                   (equal (list (car p1) (cadr p1)) (list (car p2) (cadr p2)) 1e-11)
               )
               (caddr p1)
           )
           (   (+  (caddr p1)
                   (*  (-  (caddr p2) (caddr p1))
                       (/  (distance (list (car p1) (cadr p1)) (list (car fp) (cadr fp)))
                           (distance (list (car p1) (cadr p1)) (list (car p2) (cadr p2)))
                       )
                   )
               )
           )
       )
   )                
   
   (if
       (and
           (setq p1 (getpoint "\nSpecify First Point: "))
           (setq p2 (getpoint "\nSpecify Second Point: " p1))
           (setq ss (ssget "_F" (list p1 p2) '((0 . "POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 118) (-4 . "NOT>"))))
       )
       (progn
           (repeat (setq i (sslength ss))
               (setq en (ssname ss (setq i (1- i)))
                     ed (entget  en)
                     en (entnext en)
                     vd (entget  en)
                     vl nil
               )
               (while (eq "VERTEX" (cdr (assoc  0 vd)))
                   (setq vl (cons  (cdr (assoc 10 vd)) vl)
                         en (entnext en)
                         vd (entget  en)
                   )
               )
               (if (= 1 (logand 1 (cdr (assoc 70 ed))))
                   (setq sl (cons (mapcar 'list vl (append (cdr vl) (list (car vl)))) sl))
                   (setq sl (cons (mapcar 'list vl (cdr vl)) sl))
               )
           )
           (foreach s (apply 'append sl)
               (if
                   (setq tp
                       (inters p1 p2
                           (list (caar  s) (cadar  s))
                           (list (caadr s) (cadadr s))
                       )
                   )
                   (setq pl (cons (list (car tp) (cadr tp) (_FindZOnLine tp (car s) (cadr s))) pl))
               )
           )
           (entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . ))
           (foreach x
               (vl-sort pl
                   (function
                       (lambda ( a b )
                           (<  (distance p1 (list (car a) (cadr a)))
                               (distance p1 (list (car b) (cadr b)))
                           )
                       )
                   )
               )
               (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32)))
           )
           (entmakex '((0 . "SEQEND")))
       )
   )
   (princ)
)
(vl-load-com) (princ)

 

This lisp can be found here: - 

https://www.cadtutor.net/forum/topic/33301-3d-polyline-intersection/

An interesting lisp that looks like good work between Lee Mac and David Bethel. I'd like to try it to see if it is useful to me.

Not sure why I am getting the error. I am using AutoCAD 2016.

Would appreciate help.

Thank you.

Posted

Need a extra ) to finish the 1st defun checked using a 20 year old lisp. Used Notepad++ also

 

wow.lsp

Posted
19 minutes ago, BIGAL said:

Need a extra ) to finish the 1st defun checked using a 20 year old lisp. Used Notepad++ also

 

wow.lsp

Thank you for your prompt reply Bigal.

I tried to analyse the numbers and question marks in your attached wow.lsp.

I couldn't figure out the meaning of those.

I am still unable to figure out to which line I should add the additional ).

Posted
6 hours ago, Manila Wolf said:

Looking for some help here as I have the command line message "error: extra right paren on input" when I load the following lisp: -

 


(defun c:Slice3DPoly ( / _FindZOnLine ed en i p1 p2 pl sl ss tp vd vl )

   ;; A modification by Lee Mac of the code by David Bethel found here:
   ;; http://www.cadtutor.net/forum/showthread.php?62556-3D-polyline-Intersection&p=426585&viewfull=1#post426585

   (defun _FindZOnLine ( fp p1 p2 )
       (cond
           (   (or (equal p1 p2 1e-11)
                   (equal (caddr p1) (caddr p2) 1e-11)
                   (equal (list (car p1) (cadr p1)) (list (car p2) (cadr p2)) 1e-11)
               )
               (caddr p1)
           )
           (   (+  (caddr p1)
                   (*  (-  (caddr p2) (caddr p1))
                       (/  (distance (list (car p1) (cadr p1)) (list (car fp) (cadr fp)))
                           (distance (list (car p1) (cadr p1)) (list (car p2) (cadr p2)))
                       )
                   )
               )
           )
       )
   )                
   
   (if
       (and
           (setq p1 (getpoint "\nSpecify First Point: "))
           (setq p2 (getpoint "\nSpecify Second Point: " p1))
           (setq ss (ssget "_F" (list p1 p2) '((0 . "POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 118) (-4 . "NOT>"))))
       )
       (progn
           (repeat (setq i (sslength ss))
               (setq en (ssname ss (setq i (1- i)))
                     ed (entget  en)
                     en (entnext en)
                     vd (entget  en)
                     vl nil
               )
               (while (eq "VERTEX" (cdr (assoc  0 vd)))
                   (setq vl (cons  (cdr (assoc 10 vd)) vl)
                         en (entnext en)
                         vd (entget  en)
                   )
               )
               (if (= 1 (logand 1 (cdr (assoc 70 ed))))
                   (setq sl (cons (mapcar 'list vl (append (cdr vl) (list (car vl)))) sl))
                   (setq sl (cons (mapcar 'list vl (cdr vl)) sl))
               )
           )
           (foreach s (apply 'append sl)
               (if
                   (setq tp
                       (inters p1 p2
                           (list (caar  s) (cadar  s))
                           (list (caadr s) (cadadr s))
                       )
                   )
                   (setq pl (cons (list (car tp) (cadr tp) (_FindZOnLine tp (car s) (cadr s))) pl))
               )
           )
           (entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . ))
           (foreach x
               (vl-sort pl
                   (function
                       (lambda ( a b )
                           (<  (distance p1 (list (car a) (cadr a)))
                               (distance p1 (list (car b) (cadr b)))
                           )
                       )
                   )
               )
               (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32)))
           )
           (entmakex '((0 . "SEQEND")))
       )
   )
 );<<====Put extra parenthesis here                            
   (princ)
)
(vl-load-com) (princ)

 

This lisp can be found here: - 

https://www.cadtutor.net/forum/topic/33301-3d-polyline-intersection/

An interesting lisp that looks like good work between Lee Mac and David Bethel. I'd like to try it to see if it is useful to me.

Not sure why I am getting the error. I am using AutoCAD 2016.

Would appreciate help.

Thank you.

Scroll down the Code. I've indicated where it should go with ";<<=="

Posted

The issue is on line 61. I edited the code from

(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . ))

to

(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0)  (70 . 8)))

The 70 flag was empty so I set it to  8 (is 3d polyline) and added an extra paranthesis to close the statement. Tested it on my machine and it works. Great routine by the way. Kudos to the authors.

Here's the full routine with the change in it

(defun c:Slice3DPoly ( / _FindZOnLine ed en i p1 p2 pl sl ss tp vd vl )

   ;; A modification by Lee Mac of the code by David Bethel found here:
   ;; http://www.cadtutor.net/forum/showthread.php?62556-3D-polyline-Intersection&p=426585&viewfull=1#post426585

   (defun _FindZOnLine ( fp p1 p2 )
       (cond
           (   (or (equal p1 p2 1e-11)
                   (equal (caddr p1) (caddr p2) 1e-11)
                   (equal (list (car p1) (cadr p1)) (list (car p2) (cadr p2)) 1e-11)
               )
               (caddr p1)
           )
           (   (+  (caddr p1)
                   (*  (-  (caddr p2) (caddr p1))
                       (/  (distance (list (car p1) (cadr p1)) (list (car fp) (cadr fp)))
                           (distance (list (car p1) (cadr p1)) (list (car p2) (cadr p2)))
                       )
                   )
               )
           )
       )
   )                
   
   (if
       (and
           (setq p1 (getpoint "\nSpecify First Point: "))
           (setq p2 (getpoint "\nSpecify Second Point: " p1))
           (setq ss (ssget "_F" (list p1 p2) '((0 . "POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 118) (-4 . "NOT>"))))
       )
       (progn
           (repeat (setq i (sslength ss))
               (setq en (ssname ss (setq i (1- i)))
                     ed (entget  en)
                     en (entnext en)
                     vd (entget  en)
                     vl nil
               )
               (while (eq "VERTEX" (cdr (assoc  0 vd)))
                   (setq vl (cons  (cdr (assoc 10 vd)) vl)
                         en (entnext en)
                         vd (entget  en)
                   )
               )
               (if (= 1 (logand 1 (cdr (assoc 70 ed))))
                   (setq sl (cons (mapcar 'list vl (append (cdr vl) (list (car vl)))) sl))
                   (setq sl (cons (mapcar 'list vl (cdr vl)) sl))
               )
           )
           (foreach s (apply 'append sl)
               (if
                   (setq tp
                       (inters p1 p2
                           (list (caar  s) (cadar  s))
                           (list (caadr s) (cadadr s))
                       )
                   )
                   (setq pl (cons (list (car tp) (cadr tp) (_FindZOnLine tp (car s) (cadr s))) pl))
               )
           )
           (entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0)  (70 . 8)))
           (foreach x
               (vl-sort pl
                   (function
                       (lambda ( a b )
                           (<  (distance p1 (list (car a) (cadr a)))
                               (distance p1 (list (car b) (cadr b)))
                           )
                       )
                   )
               )
               (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32)))
           )
           (entmakex '((0 . "SEQEND")))
       )
   )
   
   (princ)
)
(vl-load-com) (princ)

 

Posted
1 hour ago, dlanorh said:

Scroll down the Code. I've indicated where it should go with ";<<=="

 

Thank you for responding dlanorth.

Unfortunately I am getting the same error message after the modification?

Quite a mystery.

 

Posted

Hi,

Try this.

(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . 8))) ;; notice the number 8 along with one close paren.

 

Posted
20 hours ago, mr-blue said:

The issue is on line 61. I edited the code from


(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . ))

to


(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0)  (70 . 8)))

The 70 flag was empty so I set it to  8 (is 3d polyline) and added an extra paranthesis to close the statement. Tested it on my machine and it works. Great routine by the way. Kudos to the authors.

 

 

Mr Blue,

Thank you very much indeed. I am grateful for your help in solving this.
It is indeed an impressive routine that I will be using.
I echo the thanks to authors Lee Mac and David Bethel.

Cheers again Mr Blue.

Posted
19 hours ago, Tharwat said:

Hi,

Try this.


(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . 8))) ;; notice the number 8 along with one close paren.

 

 

Hi Tharwat,

Your eagle eye also spotted the error.
I thank you very much for also taking time to point this out.

Cheers.

Posted

@mr-blue sorry I did not notice your earlier post which you already solved the issue.

7 minutes ago, Manila Wolf said:

Hi Tharwat,

Your eagle eye also spotted the error.
I thank you very much for also taking time to point this out.

Cheers.

You are welcome anytime.

Posted

Just to clarify the old chkbrk lisp I have adds or subtracts a number for every time a ( or ) is found so the last line should be 0 meaning all brackets balance, if you have missing brackets you can look at the numbers say at the start of a while and look at end they should be the same number meaning a balance of brackets, its handy in big code.  I have started using notepad++ so much easier for checking.

Posted
On 9/1/2018 at 8:18 AM, Manila Wolf said:

Mr Blue,

Thank you very much indeed. I am grateful for your help in solving this.
It is indeed an impressive routine that I will be using.
I echo the thanks to authors Lee Mac and David Bethel.

Cheers again Mr Blue.

You're welcome! Happy I could help :)

On 9/1/2018 at 8:32 AM, Tharwat said:

@mr-blue sorry I did not notice your earlier post which you already solved the issue.

No worries, two heads are better than one! Plus, since I have just started using the forum my posts need to be moderated, it might have still been hidden when you posted.

Posted
On 9/3/2018 at 10:45 AM, mr-blue said:

.... it might have still been hidden when you posted.

Yeah, I guess that was the case.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...