Author Topic: I keep getting a "bad point argument"  (Read 3450 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
I keep getting a "bad point argument"
« on: December 29, 2017, 06:19:03 PM »
What is wrong with this bit of code?

bad point argument

Code: [Select]
(setq sca (getvar "dimscale"))
(setq pt1 (* sca 33.375))
(setq pt2 (* sca 21.4375))
(setq pt3 (* sca 31.375))
(setq pt4 (* sca 5.3125))
(ssget "CP" (list pt1 pt2 pt3 pt4))

J. Logan
ACAD 2016
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Ben Clark

  • Newt
  • Posts: 94
Re: I keep getting a "bad point argument"
« Reply #1 on: December 29, 2017, 06:23:42 PM »
You have to pass ssget a list of points. You are passing it a list of real numbers.


jlogan02

  • Bull Frog
  • Posts: 327
Re: I keep getting a "bad point argument"
« Reply #2 on: January 04, 2018, 12:37:07 PM »
I understand what you're saying, I'm just getting no where here, so I'll start at the beginning.

The coordinate points I listed are found in a title block revision history area. That title block has a dimscale of 1.0. I use those coordinate points to select all the text and lines within the revision history to;
a) to ensure the text or mtext is on a specific layer.
b) then copy the text and lines in the revision history out to the right of the border.

Now I want to multiply those coordinate points times the dimscale of a scaled drawing to copy out the revision history in them.

I can get the points and multiply them times the dimscale in my sleep now. What fail to do or understand is how take those multiplied coordinate points and create a list to get the points using crossing window or crossing polygon.

J. Logan
ACAD 2016
« Last Edit: January 04, 2018, 12:48:54 PM by jlogan02 »
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: I keep getting a "bad point argument"
« Reply #3 on: January 04, 2018, 12:44:37 PM »
Now I want to use that same idea but multiply those coordinate points times the dimscale of a scaled drawing to copy out the revision history in them.

I can get the points and multiply them times the dimscale in my sleep now. What fail to do or understand is how take those multiplied coordinate points and create a list to get the points using crossing window or crossing polygon.

The issue is that your 'multiplied points' are not points at all, they are simply numbers - the expression:
Code: [Select]
(setq pt1 (* sca 33.375))
Will return a single number, not a list of two or three numbers constituting a point.

If you already have a set of point variables (e.g. pt1, pt2, pt3, pt4), you can scale the points (from the origin) by multiplying each of the coordinate values by your scale factor, e.g.:
Code: [Select]
(mapcar '(lambda ( x ) (* x sca)) pt1)
Or:
Code: [Select]
(mapcar '* pt1 (list sca sca sca))
Or, more explicitly:
Code: [Select]
(setq pt1 (list (* (car pt1) sca) (* (cadr pt1) sca) (* (caddr pt1) sca)))

jlogan02

  • Bull Frog
  • Posts: 327
Re: I keep getting a "bad point argument"
« Reply #4 on: January 04, 2018, 01:06:49 PM »
Hi Lee,

Thanks for the quick response.

I had originally done this for a drawing with a dimscale of 8...
Code: [Select]
(setq Rev1 (mapcar '(lambda (x)(* x 8))'(31.875 5.3125 33.375 21.4375))
I didn't try to separate the points out
Quote
(mapcar '(lambda ( x ) (* x sca)) pt1)

Once I do that how do I do this...
Code: [Select]
(command "_change" Rev1 "" "p" "la" "Text2" "")
Or is there a better way?

Something like this but not entlast...
Code: [Select]
(setq en1 (entlast))
  (setq ed (entget en1))
  (setq ed (subst (cons 8 "Text2") (assoc 8 ed) ed))
(entmod ed)

(setvar "cmdecho" 0)
(princ)
)

J. Logan
ACAD 2016
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

jlogan02

  • Bull Frog
  • Posts: 327
Re: I keep getting a "bad point argument"
« Reply #5 on: January 04, 2018, 01:10:42 PM »
I kept reading the help files to say that car, cadr, and caddr were user selected points. It can be used for both user input and known points?
Code: [Select]
(setq pt1 (list (* (car pt1) sca) (* (cadr pt1) sca) (* (caddr pt1) sca)))
J. Logan
ACAD 2016
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: I keep getting a "bad point argument"
« Reply #6 on: January 04, 2018, 01:36:16 PM »
I had originally done this for a drawing with a dimscale of 8...
Code: [Select]
(setq Rev1 (mapcar '(lambda (x)(* x 8))'(31.875 5.3125 33.375 21.4375))

I don't understand what the numbers in your example are referring to? - i.e. what are (31.875 5.3125 33.375 21.4375)?

This is evidently not a point, and the mapcar expression will simply return a list of 4 numbers multiplied by 8.

Once I do that how do I do this...
Code: [Select]
(command "_change" Rev1 "" "p" "la" "Text2" "")
Or is there a better way?

Yes, assuming your variable 'Rev1' will eventually be assigned a selection set, you can iterate over the selection set to have more control over the objects you are modifying.

I kept reading the help files to say that car, cadr, and caddr were user selected points. It can be used for both user input and known points?
Code: [Select]
(setq pt1 (list (* (car pt1) sca) (* (cadr pt1) sca) (* (caddr pt1) sca)))

car, cadr, and caddr are not points at all - they are AutoLISP functions which may be used respectively to retrieve the first, second, and third elements of a list. As such, when supplied with a list representing a set of coordinate values, (car <list>) will return the x-coordinate, (cadr <list>) the y-coordinate, and (caddr <list>) the z-coordinate.

I think you would benefit from reading these posts/tutorials:

http://ronleigh.com/autolisp/ales11.htm
http://www.theswamp.org/index.php?topic=39025.msg442238#msg442238

http://www.theswamp.org/index.php?topic=45131.msg503433#msg503433
http://www.theswamp.org/index.php?topic=31473.0

jlogan02

  • Bull Frog
  • Posts: 327
Re: I keep getting a "bad point argument"
« Reply #7 on: January 04, 2018, 01:50:41 PM »
Sorry about that. I should have stated those are coordinate points that would represent the lower left and upper right of a window, crossing or other wise.

I am trying to select everything inside those coordinates. Those coordinates are found in the revision history area of a drawing with a dimscale of 1.0

If I know those points I should be able to multiply them times the dimscale of any drawing to select the objects found within those coordinates * dimscale.

31.875 5.3125 = Lower right corner of window
33.375 21.4375 = Upper right corner of window
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: I keep getting a "bad point argument"
« Reply #8 on: January 04, 2018, 02:07:17 PM »
Sorry about that. I should have stated those are coordinate points that would represent the lower left and upper right of a window, crossing or other wise.

31.875 5.3125 = Lower right corner of window
33.375 21.4375 = Upper right corner of window

OK, but in the current list structure, they are not points.

You have a couple of options here:


The points could be expressed as separate variables, e.g.:
Code: [Select]
(setq pt1 '(31.875 5.3125)
      pt2 '(33.375 21.4375)
)

And then scaled from the origin by the dimscale using:
Code: [Select]
(setq dim (getvar 'dimscale)
      pt1 (mapcar '* pt1 (list dim dim))
      pt2 (mapcar '* pt2 (list dim dim))
)

And then supplied to the ssget function in the following way:
Code: [Select]
(ssget "_C" pt1 pt2)


Or alternatively, expressed as a single list of points:
Code: [Select]
(setq lst '((31.875 5.3125) (33.375 21.4375))
Then (car lst) would yield the lower-left corner, and (cadr lst) would yield the upper-right.

Scaling these coordinates from the origin by the dimscale would be then achieved using:
Code: [Select]
(setq dim (getvar 'dimscale)
      lst (mapcar '(lambda ( x ) (mapcar '* x (list dim dim))) lst)
)

This list of window points could then be supplied to the ssget function in the following way:
Code: [Select]
(apply 'ssget (cons "_C" lst))

Ben Clark

  • Newt
  • Posts: 94
Re: I keep getting a "bad point argument"
« Reply #9 on: January 04, 2018, 02:07:49 PM »
jlogan42,

You are still missing the underlying problem here that has been pointed out twice.

Number are not points, they're numbers. In autolisp, points are expressed as either a 2 or 3 element long list. i.e.


This is a number:
5

This is a 2d point:
(5 5)

This is a 3d point:
(5 5 5)

This is how you define a 3d point:
(setq pt1 (list 5 5 5))

or alternatively
(setq pt1 '(5 5 5))

pt1 is now a variable holding a point where x=5, y=5, z=5

The following defines a number, not a point
(setq a 5)

"a" is now a variable holding the number 5


When you're using ssget with "CP" as its first argument, it then expects to find a list of points as its next argument.

A list of points could be defined like this:

(setq ptlist (list (list 1 2 3) (list 4 5 6) (list 7 8 9))

You could also use the quote symbol. Read Lee Mac's write up on using it:
http://www.lee-mac.com/quote.html



This is why you're getting an error when using ssget. Hopefully this clears it up.

JohnK

  • Administrator
  • Seagull
  • Posts: 10649
Re: I keep getting a "bad point argument"
« Reply #10 on: January 04, 2018, 03:24:10 PM »
A friendly reminder to the more experienced users of this forum to use the custom code tag we worked so hard implementing into this forum whenever you can (or when/are offering help). The improved code tags allow newer users to get help on Autolisp functions by selecting the hyperlinks.
https://www.theswamp.org/index.php?topic=48309.0


EDIT: Or you can also pass along a hyperlink to a function with the following url syntax.
EG:
SSGET: http://www.theswamp.org/~john/avlisp/#ssget
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

jlogan02

  • Bull Frog
  • Posts: 327
Re: I keep getting a "bad point argument"
« Reply #11 on: January 08, 2018, 03:17:28 PM »
Thanks Lee and Ben for straightening me out. Much appreciated.

J. Logan
ACAD 2016
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10