Opposite corner bad element in arguments list:

Opposite corner bad element in arguments list:

jaggisingh003
Advocate Advocate
1,129 Views
9 Replies
Message 1 of 10

Opposite corner bad element in arguments list:

jaggisingh003
Advocate
Advocate

hello, Everyone please help me here I m working on something but get an error of 

This:- First corner? Opposite corner bad element in arguments list: -388945.0

 

Code is Here,

(defun C:c1 (/ P1 P3 SS S2 S3 S4 S5 S6 SS1 SS2 SS3 SS4 POINT1 POINT2 POINT3 POINT4 POINT5)
(setq p1 (getpoint "\nFirst corner ? "))
(setq p3 (getcorner pta "\nOpposite corner "))
(setq ptlist (list (setq xc1 (list(car p1)(cadr p1)))
(setq yc1 (list(car p3)(cadr p3)))
(setq xc2 (list(car p3)(cadr p1)))
(setq yc2 (list(car p1)(cadr p3)))))
(setq ss (ssget "WP" (ptlist) '((0 . "TEXT")(1 . "B-150"))))
(setq s2 (ssget "WP" (ptlist) '((0 . "TEXT")(1 . "B-175"))))
(setq s3 (ssget "WP" (ptlist) '((0 . "TEXT")(1 . "B-200"))))
(setq s4 (ssget "WP" (ptlist) '((0 . "TEXT")(1 . "B-225"))))
(setq s5 (ssget "WP" (ptlist) '((0 . "TEXT")(1 . "B-250"))))
(setq s6 (ssget "WP" (ptlist) '((0 . "TEXT")(1 . "TTC"))))
(setq ss (sslength ss))
(setq ss1 (rtos ss 2 0))
(setq s2 (sslength s2))
(setq ss2 (rtos s2 2 0))
(setq s3 (sslength s3))
(setq ss3 (rtos s3 2 0))
(setq s4 (sslength s4))
(setq ss4 (rtos s4 2 0))
(setq s5 (sslength s5))
(setq ss4 (rtos s5 2 0))
(setq s6 (sslength s6))
(setq ss6 (rtos s6 2 0))
(setq point1 (getpoint "\n Selcted point for B-150"))
(setq point2 (getpoint "\n Selcted point for B-175"))
(setq point3 (getpoint "\n Selcted point for B-200"))
(setq point4 (getpoint "\n Selcted point for B-225"))
(setq point5 (getpoint "\n Selcted point for B-250"))
(setq point6 (getpoint "\n Selcted point for TTC"))
(command "text" "j" "l" point1 2 0 ss1)
(command "text" "j" "l" point2 2 0 ss2)
(command "text" "j" "l" point3 2 0 ss3)
(command "text" "j" "l" point4 2 0 ss4)
(command "text" "j" "l" point5 2 0 ss5)
(command "text" "j" "l" point6 2 0 ss6))

 

help me 

0 Likes
Accepted solutions (2)
1,130 Views
9 Replies
Replies (9)
Message 2 of 10

johnyDFFXO
Advocate
Advocate

@jaggisingh003 wrote:

hello, Everyone please help me here I m working on something but get an error of 

This:- First corner? Opposite corner bad element in arguments list: -388945.0

 

Code is Here,

(defun C:c1 (/ P1 P3 SS S2 S3 S4 S5 S6 SS1 SS2 SS3 SS4 POINT1 POINT2 POINT3 POINT4 POINT5)
(setq p1 (getpoint "\nFirst corner ? "))
(setq p3 (getcorner pta "\nOpposite corner "))
(setq ptlist (list (setq xc1 (list(car p1)(cadr p1)))
(setq yc1 (list(car p3)(cadr p3)))
...

 

help me 


 

Shouldn't pta rather be p1?

Message 3 of 10

jaggisingh003
Advocate
Advocate

Oop's that is a mistake. \

After corrected that point the result is the same. 🤔

0 Likes
Message 4 of 10

CodeDing
Advisor
Advisor
Accepted solution

@jaggisingh003 ,

 

I didn't spend much time analyzing where your error might come from since your code is quite repetitive.

Perhaps something more like this would work better for you?

(defun c:TEST ( / p1 p2 p3 txtList len)
  (initget 1) (setq p1 (getpoint "\nFirst corner: "))
  (initget 1) (setq p2 (getcorner p1 "\nOpposite corner: "))
  (setq txtList '("B-150" "B-175" "B-200" "B-225" "B-250" "TTC"))
  (foreach txt txtList
    (setq len
      (if (setq ss (ssget "_W" p1 p2 (list '(0 . "TEXT") (cons 1 txt))))
        (sslength ss)
        0
      );if
    );setq
    (initget 1) (setq pt3 (getpoint (strcat "\nSelected point for " txt ": ")))
    (command "_.TEXT" "j" "l" pt3 2 0 (itoa len))
  );foreach
  (princ)
);defun

Best,

~DD

Message 5 of 10

Anonymous
Not applicable

 

maybe i don't understand good your problem in case let me understand better writing more about....

 

 

i think your problem is try to get one corner using one variable pta at place to p1 variable

and also don't use initget to force the getpoint to have one point at place to receive one enter.... 

 

....

(setq p1 (getpoint "\nFirst corner ? "))
(setq p3 (getcorner pta "\nOpposite corner "))

....

 

so this for start to understand the problem:

....

(setq p1 (getpoint "\nFirst corner?  "))
(setq p3 (getcorner p1 "\nOpposite corner "))

....

 

but you need maybe force the getpoint to have receive oe poit and not one enter

so use before getpoint initget

 

....

(initget 1)

(setq p1 (getpoint "\nFirst corner:"))
(setq p3 (getcorner p1 "\nOpposite corner:"))

....

 

of maybe you like really don't select First corner using getpoint  and set pt1 (maybe you have one default First corner pta?) so try this:

 

.....

(setq pta '(ptax ptay ptaz))  ;  one first corner ready for use maybe you have.....

.....

; from one other procedure and as pubblic variable......

 

....

(setq p1 (getpoint "\nFirst corner <or use pta>:"))

(setq p3 (if p1 (getcorner p1  "\nOpposite corner:")

                          (getcorner pta "\nOpposite corner:")))

....

 

i hope this is your problem......

Giovanni 

 

0 Likes
Message 6 of 10

jaggisingh003
Advocate
Advocate

thanks for your help, my friend.

 

it is works great for me. 

0 Likes
Message 7 of 10

jaggisingh003
Advocate
Advocate

@CodeDing here is a problem in this code this will give only B-150 value other value marking 0. but in the list other values present. 

Here is the attached drawing. 

  

0 Likes
Message 8 of 10

CodeDing
Advisor
Advisor
Accepted solution

@jaggisingh003 ,

 

My mistake. Thank you for the drawing. it helped. Here is the updated version:

(defun c:TEST ( / p1 p2 p3 ss txtList osm)
  (initget 1) (setq p1 (getpoint "\nFirst corner: "))
  (initget 1) (setq p2 (getcorner p1 "\nOpposite corner: "))
  (setq osm (getvar 'OSMODE)) (setvar 'OSMODE (logior 16384 osm))
  (setq txtList '("B-150" "B-175" "B-200" "B-225" "B-250" "TTC"))
  (command "_.ZOOM" "w" p1 p2)
  (setq txtList
    (mapcar
      '(lambda (txt)
        (cons txt
          (itoa (if (setq ss (ssget "_W" p1 p2 (list '(0 . "TEXT") (cons 1 txt)))) (sslength ss) 0))
        );cons
      );lambda
      txtList
    );mapcar
  );setq
  (command "_.ZOOM" "p")
  (setvar 'OSMODE osm)
  (foreach txt txtList
    (initget 1) (setq pt3 (getpoint (strcat "\nSelected point for " (car txt) ": ")))
    (prompt (cdr txt))
    (setvar 'CMDECHO 0) (command "_.TEXT" "j" "l" "_non" pt3 2 0 (cdr txt)) (setvar 'CMDECHO 1)
  );foreach
  (setq ss nil)
  (princ)
);defun

Best,

~DD

Message 9 of 10

jaggisingh003
Advocate
Advocate

Can you tell what is the issue in the previous code.

Message 10 of 10

CodeDing
Advisor
Advisor

@jaggisingh003 ,

 

Sure thing..

 

In my original code, we get the 2 corners very first thing..

(initget 1) (setq p1 (getpoint "\nFirst corner: "))
(initget 1) (setq p2 (getcorner p1 "\nOpposite corner: "))

 

Then, within the foreach loop, I use the Window style selection set to get the text elements for that particular loop..

  (if (setq ss (ssget "_W" p1 p2 (list '(0 . "TEXT") (cons 1 txt)))) ...

 

Now, within that SAME iteration of the loop, I ask the user to place the new text somewhere..

  (initget 1) (setq pt3 (getpoint (strcat "\nSelected point for " txt ": ")))

 

So, when the NEXT LOOP comes around, our user has ALREADY Zoomed to another part of the drawing area.

This is an issue because the Window style selection set will ONLY select elements that are in the current view.

So, since the user has already zoomed to a smaller portion of the drawing area, now there are None of the text elements in view..

 

That is why it would not work.

 

So, in my revised code, I instead zoomed to the user-selected area first.. Collected all relevant information and stored it in a variable.. Then allowed the user to navigate to the area where they want to place the new text.

 

Hope that clears it up for you.

Best,

~DD