Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i need help for bug

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
720 Views, 10 Replies

i need help for bug

Hello

 

i want to select blocks on multiple polyline at once with the inserting pont of block.

 

so he dont want to work;

 

(defun c:test (/ js fence ss i pl)
(or
(setq js (ssget "_I"))
(setq js (ssget "_P"))
)
(cond
(js
(sssetfirst nil js)
(initget "Existant Nouveau _Existent New")
(if (eq (getkword "\nTraiter jeu de sélection [Existant/Nouveau] <Existant>: ") "New")
(progn (sssetfirst nil nil) (setq js (ssadd) js (ssget)))
)
)
(T (setq js (ssget)))
)
(cond
(js
(setq fence (listpol(ssname js (setq n (1- n)))))
setq ss (ssget "_F" fence '((0 . "INSERT"))))
(repeat (setq i (sslength ss))
(setq pl (cons (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) pl))
)
)
)

;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;

(defun listpol (en / i p l)
(setq i (if (vlax-curve-IsClosed en)
(vlax-curve-getEndParam en)
(+ (vlax-curve-getEndParam en) 1)
)
)
(while (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
(setq l (cons (trans p 0 1 ) l))
)
)

 

 

 

10 REPLIES 10
Message 2 of 11
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... 

so he dont want to work;

....

(setq fence (listpol(ssname js (setq n (1- n)))))
setq ss (ssget "_F" fence '((0 . "INSERT"))))
(repeat (setq i (sslength ss))
....


It may not be the only problem, but one thing I noticed -- the above should be:

 

....

(setq fence (listpol(ssname js (setq n (1- n)))))
(setq ss (ssget "_F" fence '((0 . "INSERT"))))
(repeat (setq i (sslength ss))
....

Kent Cooper, AIA
Message 3 of 11
Anonymous
in reply to: Kent1Cooper

So thank you 

 

I found another problems but now i don't know where is the probleme.

 

if you can look.

 

(defun c:test (/ ename fence ss j pl)
(or
(setq js (ssget "_I"))
(setq js (ssget "_P"))
)
(cond
(js
(sssetfirst nil js)
(initget "Existant Nouveau _Existent New")
(if
(eq (getkword
"\nTraiter jeu de sélection [Existant/Nouveau] <Existant>: "
)
"New"
)
(progn (sssetfirst nil nil)
(setq js (ssadd)
js (ssget)
)
)
)
)
(T (setq js (ssget)))
(cond
(js
(repeat (setq i (sslength js))
(setq ename (ssname js (setq i (1- i)))
fence (listpol ename)
ss (ssget "_F" fence '((0 . "INSERT")))
(repeat (setq i (sslength ss))
(setq pl
(cons
(cdr (assoc 10
(entget (ssname ss (setq j (1- j))))
)
)
pl
)
)
)
)
)

;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;

(defun listpol (en / i p l)
(setq i (if (vlax-curve-IsClosed en)
(vlax-curve-getEndParam en)
(+ (vlax-curve-getEndParam en) 1)
)
)
(while
(setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
(setq l (cons (trans p 0 1) l))
)
)
)
)
)
)

Message 4 of 11
Anonymous
in reply to: Anonymous

You will likely get "case sensitivity" issues with this code, try looking into the (strcase) function, specifically for these lines of code

(initget "Existant Nouveau _Existent New")
(if
(eq (getkword
"\nTraiter jeu de sélection [Existant/Nouveau] <Existant>: "
)
"New"
)

 I may not be correct but perhaps that will help you.

Gl and thanks.

Message 5 of 11
Kent1Cooper
in reply to: Anonymous

Using indentation to clarify the left- and right-parenthesis pairs, I find some apparent parentheses issues [I hope I'm correctly interpreting the sequence of events].  You could also pull the definition of listpol fully outside the C:TEST command definition, which would move another of the right parentheses earlier.

 

(defun c:test (/ ename fence ss j pl)
  (or
    (setq js (ssget "_I"))
    (setq js (ssget "_P"))
  ); or
  (cond [1]
    (js ; selection exists implied or previous
      (sssetfirst nil js)
      (initget "Existant Nouveau _Existent New")
      (if (eq (getkword "\nTraiter jeu de sélection [Existant/Nouveau] <Existant>: ") "New")
        (progn ; then
          (sssetfirst nil nil)
          (setq
            js (ssadd); not necessary [next line will override]
            js (ssget)
          ); setq
        ); progn
      ); if
    ); js-exists condition
    (T ; doesn't exist -- get some
      (setq js (ssget))
    ); doesn't-exist condition

  );;;;; END COND [1]
  (cond [2]
    (js ; selection exists from whichever method from above
      (repeat (setq i (sslength js))
        (setq
          ename (ssname js (setq i (1- i)))
          fence (listpol ename)
          ss (ssget "_F" fence '((0 . "INSERT")))
        );;;;; END SETQ
      );;;;; END REPEAT
      (repeat (setq i (sslength ss));;;;; [AS YOU HAD IT, THIS WILL TRY TO BE A VARIABLE NAME]
        (setq pl
          (cons
            (cdr (assoc 10 (entget (ssname ss (setq j (1- j))))))
            pl
          ); cons
        ); setq
      ); repeat
    ); js-exists condition
  ); cond [2]
;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;

  (defun listpol (en / i p l)
    (setq i
      (if (vlax-curve-IsClosed en)
        (vlax-curve-getEndParam en); then
        (+ (vlax-curve-getEndParam en) 1); else
      ); if
    ); setq
    (while
      (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
      (setq l (cons (trans p 0 1) l))
    ); while
  ); defun -- listpol
;;;;;);;;;; MOVED EARLIER
;;;;;);;;;; MOVED EARLIER
;;;;;);;;;; MOVED EARLIER
); defun -- C:TEST

Kent Cooper, AIA
Message 6 of 11
Anonymous
in reply to: Kent1Cooper

So was the strcase not needed?

Message 7 of 11
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

So was the strcase not needed?


Not in this case.  When you use (initget)/(getkword), the returned string is always in the same case combination as where it's listed inside (initget), regardless of the case(s) the User types.  Whether they type n or N or ne or NE or nE or Ne or new or New or NEW or nEw or neW or NeW or NEw or nEW, the returned string will always be "New" as in (initget)'s options list.

 

Command: (initget "New Old")

Command: (getkword "Which? ")
Which? NEW ;; <-- typed
"New" ;; <-- returned

Kent Cooper, AIA
Message 8 of 11
Anonymous
in reply to: Kent1Cooper

I see. Thank you for clearing that up for me.

Another kudos incoming!! 😄

Message 9 of 11
Anonymous
in reply to: Kent1Cooper

thank you

 

Just can you explain me what you tell this will try to be a variable name because when i use it the return is this error:

 

 no function definition: LISTPOL

 

I want to kwon where does she come.

 

Message 10 of 11
Anonymous
in reply to: Anonymous

;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;

  (defun listpol (en / i p l)
    (setq i
      (if (vlax-curve-IsClosed en)
        (vlax-curve-getEndParam en); then
        (+ (vlax-curve-getEndParam en) 1); else
      ); if
    ); setq
    (while
      (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
      (setq l (cons (trans p 0 1) l))
    ); while
  ); defun -- listpol

 

 

right there in the routine

Message 11 of 11
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

... when i use it the return is this error:

 

 no function definition: LISTPOL

,,,,


I didn't think of that -- it would be a reason to pull the definition of (listpol) outside of the definition of C:TEST.  If they are together in a file, once you load it, both will be defined.  As it is, I think it's reaching a use of the (listpol) function before it reaches the definition of it.  You could also fix it by moving the definition of (listpol), still inside the definition of C:TEST, up to the beginning of it, so that (listpol) is defined before it's used.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost