Jump to content

Recommended Posts

Posted

I must have missed this part in the tutorials and so far searching comes up with nothing that fits this. I have a list like this:

'(13.5 16.75)

I want to let one of the values be a variable but when I try this:

'(pos1 16.75)

I get a DXF error?

Posted

Using quote to a list will prevent AutoLISP to evaluate the content; for second case consider LIST function.

([color=red]list[/color] pos1 16.75)

Posted

Try searching on the QUOTE Symbol; I recall Lee having a good tutorial on this.

 

In short, by using ' (aka QUOTE symbol) you've told LISP to not evaluate the expression, but to take it at face value.

 

 

 

If the desired output is a list:

 

(list pos1 16.75)

 

 

 

... And for grouped pair:

 

(cons pos1 16.75)

  • 2 weeks later...
Posted

Thanks all. I've been working on new projects and getting spoiled on Visual Studio and it's intellisense editor. But still have to keep up with AutoCAD side of it. This was great advice.

  • 7 months later...
Posted

I had to revist this one today. I tried the above advice but still seem to be getting no where with it. The code is like this:

(setq bbn (* (+ 119.5 (/ dim_b 2.)) -1))
(setq bbx (+ 116.5 (/ dim_a 2.)))
;;;(hgrt '(-148.0 143.0))
(hgrt (list bbn bbx))

The commented line shows how the function gets called successfully so now I'd like to pass variables that are the results of the equations above. But I keep getting this error:

; error: bad argument type: 2D/3D point: (-148.0 . 153.0)

 

I've also tried

(hgrt (cons bbn bbx))
 and
(hgrt '(bbn bbx))

Posted

(hgrt (list bbn bbx))

This code should work perfectly. I find it helps to put certain lines of code directly into autocad to see what it returns. I.E. If you type (list 1 2) into autocad, it will return (1 2). Also, if you want to see what data is stored in a variable, use and exclamation point and tyoe the variable name into the autocad command line. IE !bbn

 

Play around with it a bit and see if something is wrong with your variables.

Posted

Thanks. I must have been hallucinating but I'm really sure I tried it that way at least once. Probably forgot something like loading the code after I changed it. Anyway, the code you confirm is working now.

Posted

Also, FWIW Bill, you can simply modify your sub-function to accept two arguments, rather than a single, two element list as argument. You're currently having to build the list to pass as a single, only parameter, then presumable having to extract respective list elements within the sub-function... More work, same result.

 

Cheers

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...