Jump to content

Creating Point Lists From Local Variables..?


Recommended Posts

Posted

Hi,

 

Just trying to get my head around the process to define points/co-ordinates base on the DIMSCALE, so I have the follow 2 variations of code - the difference between the two is coloured red.

 

(DEFUN C:test ( / xcoord ycoord bpt )
(setq xcoord (* (getvar "dimscale") 424))
(setq ycoord (* (getvar "dimscale") 96))
[color="red"](setq bpt (list xcoord ycoord))[/color]
(command "line" bpt)
(princ)
)

 

(DEFUN C:test ( / xcoord ycoord bpt )
(setq xcoord (* (getvar "dimscale") 424))
(setq ycoord (* (getvar "dimscale") 96))
[color="red"](setq bpt '(xcoord ycoord))[/color]
(command "line" bpt)
(princ)
)

 

My question is, why does the first code work, but the second fails? No error message is given. Where am I going wrong with the list quoting?

 

Thanks a lot for any help.

Posted

I've run across this same thing before. I don't know much, but here's what I do know:

 

After removing the declared variables (DEFUN C:test (), and banging (!bpt)...

 

The first case returns: (424.0 96.0), the second: (XCOORD YCOORD).

 

So I'd guess maybe they're both ways to create a list, the first is designed for when you need an integer returned, the second way is for if your code needs a string returned? I'm interested to know the real answer, good luck! :P

Posted

Good point LosGirk. Perhaps quoting the variables adds the variables to the list, rather than the values of the variables.

 

Thanks for the reply.

Posted
Good point LosGirk. Perhaps quoting the variables adds the variables to the list, rather than the values of the variables.

 

That's exactly how it works....

Posted

Understood (now). Thanks a lot for the input guys.

 

Great article Lee, thanks also for providing the link Marko.

Posted
Great article Lee, thanks also for providing the link Marko.

 

Thank you lamensterms - I'm glad that the explanation was clear :thumbsup:

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