Author Topic: testing if  (Read 2514 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
testing if
« on: August 17, 2005, 10:59:22 AM »
if i'm trying to branch my code testing whether the value for assoc 50 is 0 or not how do i write that. i've tried many different variations and it keeps saying :

error: too few arguments: (IF (= ( ... )))
or
; error: extra cdrs in dotted pair on input


Code: [Select]
(if (= (assoc 50  0.0 txtlist)))


UUUUUUUUUUUUUUGGGGGGGGGGGGGGHHHHHHHHHHHHH  :evil:

ELOQUINTET

  • Guest
testing if
« Reply #1 on: August 17, 2005, 11:01:12 AM »
or better yet how do i test if this value is not 0?

whdjr

  • Guest
testing if
« Reply #2 on: August 17, 2005, 11:13:32 AM »
First of all you have too many elements in your assoc function.
Code: [Select]
(if (= (cdr (assoc 50 txtlist)) 0.0)

You might need to test to make sure the number is a real or an integer.

ELOQUINTET

  • Guest
testing if
« Reply #3 on: August 17, 2005, 11:42:54 AM »
here is basically what i'm trying to do will. it's to relocate text under the dimension when it has been stretched. it works on horizontal dims but for vertical it moves the text along the x coord not the y. does this have to do with me using assoc 11 for both? not sure how to get it to move along the y coord?

Code: [Select]
(defun c:MTOentmod (/)
 
  (setq osm (getvar 'osmode))
  (setvar "osmode" 0)
    (setq   txtentity (car (entsel "\nSelect text: "))
   txtlist   (entget txtentity)
   pt1      (cdr (assoc 11 txtlist))
   x1        (car pt1)
            y1        (cadr pt1)
    )  
    (setq   dimentity (car (entsel "\nSelect dimension: "))
   dimlist   (entget dimentity)
   pt2      (cdr (assoc 11 dimlist))
   x2        (car pt2)
   y2        (cadr pt2)
    )
(if (= (cdr (assoc 50 txtlist)) 0.0)
  (setq  txtxcoord (car pt2)
            txtycoord (cadr pt1)
            pt3 (list txtxcoord txtycoord 0)
            new (cons 11 pt3)
   old (cons 11 pt1)
            txtlist (subst new old txtlist)
     )
  (setq   txtxcoord (car pt1)
            txtycoord (cadr pt2)
            pt3 (list txtxcoord txtycoord 0)
   new (cons 11 pt3)
   old (cons 11 pt1)
            txtlist (subst new old txtlist)
 )
)
      (entmod txtlist)
    (setvar 'osmode osm)
    (princ)
  )
 

ELOQUINTET

  • Guest
testing if
« Reply #4 on: August 17, 2005, 01:05:50 PM »
aha i got it i needed to test dimlist not txtlist. it works now.

(sarcasm) that was easy, next (sarcasm)

i love talking to myself, can ya tell

whdjr

  • Guest
testing if
« Reply #5 on: August 17, 2005, 01:13:47 PM »
You talk very well to yourself E. :)

pmvliet

  • Guest
testing if
« Reply #6 on: August 17, 2005, 01:27:13 PM »
I have done it too...
Post a question and either as I am posting I realize the answer or a few more minutes playing with the issue, the lightbulb goes on  :idea:

I believe they call it learning...  :D

Pieter