if statement not recognizing variable setting

Discussion in 'AutoCAD' started by Jamie Richardson, Jul 22, 2003.

  1. I have a lsp routing below where I do a search for all of the model
    space views in the drawing and build a list.
    (while (setq viewnames (tblnext "view" (not viewnames)))
    (if (= (cdr (assoc 70 viewnames)) 0)
    (setq viewlist-1 (append viewlist-1 (list (cdr (assoc 2
    viewnames)))))
    )
    )

    I than set user-vname to a view name in the list. (below is one of my
    ways of doing this)
    (setq user-vname (car viewlist-1))

    I than get the x and y dimension of the view to determine a sheet size
    (setq view_y (/(cdr(assoc 40(tblsearch "view" user-vname)))(getvar
    "dimscale")))
    (setq view_x (/(cdr(assoc 41(tblsearch "view" user-vname)))(getvar
    "dimscale"))

    Than I check it and set the appropriate sheet size.
    (if (and (= view_x 42.0) (= view_y 30.0))
    (setq plsize "ER&A (30.00 x 42.00 Inches)")
    (setq plsize nil)
    )

    If view_y = 30.0 and view_x = 42.0 (whick it is) than, plsize should be
    set to "ER&A (30.00 x 42.00 Inches)" instead it is set to nil. The only
    way I can get this to work is if I use the "fix" as shown below. But
    this will drop any fraction or decimal which is causing some problems in
    the program.
    (setq view_y (fix(/(cdr(assoc 40(tblsearch "view" user-vname)))(getvar
    "dimscale"))))
    (setq view_x (fix(/(cdr(assoc 41(tblsearch "view" user-vname)))(getvar
    "dimscale"))))

    Is there another way to do this? Should I be going about this a whole
    different way?
    thanks for any help
     
    Jamie Richardson, Jul 22, 2003
    #1
  2. Jamie Richardson

    MarieDez Guest

    I already had a problem similar as this one. Sometimes when AutoCAD compare 2 real numbers,like (= 42.0 42.0) it doesn't work. The only way I found to fix the problem is to convert the 2 numbers into ascii text with the RTOS function, compare the 2 numbers and reconvert it after with ATOF. With this, you can keep the number of decimal you need.

    I hope this will help you

    Marie
     
    MarieDez, Jul 22, 2003
    #2
  3. Jamie Richardson

    Mark Propst Guest

    'never' use = for numeric tests
    (setq fuzz 0.0000001)
    (equal 42.00000001 42.0 fuzz)
    T
    _$
     
    Mark Propst, Jul 22, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.