ssget point list for "wp" or "cp selection

ssget point list for "wp" or "cp selection

aliozcicek
Contributor Contributor
3,878 Views
11 Replies
Message 1 of 12

ssget point list for "wp" or "cp selection

aliozcicek
Contributor
Contributor

can I ask you about smilar problem? 

 

I have problem with "ssget" and "point list". after some code I got one point list like this....

((1322.2 31.6559) (1322.2 31.9501) (1313.8 31.9501) (1313.8 31.6559) (1314.04 31.4159) (1313.8 26.6457))

and I named it "ptlist" (also I have some other parameters for selection set like PAR1 PAR2.... )

(setq sec (ssget "CP" ptlist (list (cons 8 PAR1) (cons 40 PAR2) (cons 7 PAR3))))

when I use this code it is ending with

"; error: bad function: 1322.2"

where is my fault?

0 Likes
Accepted solutions (4)
3,879 Views
11 Replies
Replies (11)
Message 2 of 12

pbejse
Mentor
Mentor

Should define your list as 

 

like this

(setq ptlist '((1322.2 31.6559) (1322.2 31.9501) (1313.8 31.9501) (1313.8 31.6559) (1314.04 31.4159) (1313.8 26.6457))) not (setq ptlist (list (1322.2 31.6559) (1322.2 31.9501) (1313.8 31.9501) (1313.8 31.6559) (1314.04 31.4159) (1313.8 26.6457))) and not (setq ptlist ((1322.2 31.6559) (1322.2 31.9501) (1313.8 31.9501) (1313.8 31.6559) (1314.04 31.4159) (1313.8 26.6457)))

 

Message 3 of 12

Kent1Cooper
Consultant
Consultant

@aliozcicek wrote:

...". after some code I got one point list like this....

((1322.2 31.6559) (1322.2 31.9501) (1313.8 31.9501) (1313.8 31.6559) (1314.04 31.4159) (1313.8 26.6457))

....


I was wondering the same thing as @pbejse, but I suppose the form of the list as shown above doesn't necessarily mean it wasn't constructed in the right way.  If the "some code" built the list as a variable, out of points from other variables and/or User picks, and you asked it to show you what's in the list variable, it would be shown like that, without  showing the apostrophe before the beginning that you would need if typing it into a (setq) function to define the list.

 

Is what's shown above the return from calling for what's in the variable at the command line, with the preceding exclamation point, like this?

 

!YourListVariableName

 

If not, can you post more of the code that defines the list?  Aside from the apostrophe question, what surrounds that may be incorrect in some other way -- a parentheses problem, or something -- making it arrive at that 1322.2 in a way that makes it think it's a function name and not an item in a list.

Kent Cooper, AIA
Message 4 of 12

aliozcicek
Contributor
Contributor

thanks for help guys.

 

I understand what I have only one member list when got,

((1322.2 31.6559) (1322.2 31.9501) (1313.8 31.9501) (1313.8 31.6559) (1314.04 31.4159) (1313.8 31.1759) (1313.8 26.6457) (1322.2 26.6457) (1322.2 31.1759) (1321.96 31.4159)) this.

and I extract it then I have all point list. now I can use it as point list.

for the take vertex coordinates I use that code (which I saw in autodesk forum before),

.....

(defun massoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)

(setq ptlst (massoc 10 (entget (car (entsel"\Seçim alanını seçiniz !")))))

(setq ptlst2 (car ptlst))

 

now I can set some spesific selection sets in any polyline.

0 Likes
Message 5 of 12

aliozcicek
Contributor
Contributor
Accepted solution

something strange...

 

after I understand the stiuation I write same code but now it returns 10 member list. and I use it easily. I don't remember what I changed something but now it works as I expect... 

 

....

(defun massoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)

(setq ptlst (massoc 10 (entget (car (entsel"\Seçim alanını seçiniz !")))))
(ssget "_CP" ptlst)

....

 

really can't understand but it solved....

 

 

thanks anyway for recommendations... 

0 Likes
Message 6 of 12

Kent1Cooper
Consultant
Consultant

@aliozcicek wrote:

....

for the take vertex coordinates I use that code (which I saw in autodesk forum before),

....


If that is the way your 'ptlist' variable is defined, I don't see any reason why it shouldn't work for defining a Crossing-Polygon in an (ssget) function.  [There's a shorter way to get that point list from a Polyline, but the resulting list would be the same.]  I can think of reasons that nothing would be found, but not any reason for the error message you describe in Post 1....

[Never mind, if the problem has gone away.]

Kent Cooper, AIA
0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

@aliozcicek wrote:

.... I don't remember what I changed something but now it works as I expect... 

...
(ssget "_CP" ptlst)

...

really can't understand but it solved....


Could it be the underscore character?  That lets English options and abbreviations work in non-English versions of AutoCAD, and it wasn't in the code in Post 1.

Kent Cooper, AIA
0 Likes
Message 8 of 12

aliozcicek
Contributor
Contributor

only now I see that differences. you might be right Kent Cooper, 

 

another question in my mind. you think I have long way to get point list of polygon for creating sellection set in this polygon? actually I am such a begginner for lisp and I am trying to improve myself with all posts of this community.

 

let me show my aim.

  • there is one polygon ( actually I created it by another lisp).
  • in this polyygon I have some texts and blocks
  • I try to connect that bloks to texts and I then I need to extract to excell. this is need for my final account of current project.

dravings look like that... cyan one text... and other colors mean another blocks...  

 

kiriş.jpg

 

thanks for help and advices...

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

@aliozcicek wrote:

.... 

another question in my mind. you think I have long way to get point list of polygon for creating sellection set in this polygon? actually I am such a begginner for lisp and I am trying to improve myself with all posts of this community.

....


The shorter way that I would use would be like this:

 

(setq ptlst (vl-remove-if '(lambda (x) (/= (car x) 10)) (entget (car (entsel"\Seçim alanını seçiniz !")))))

 

without the need for that (massoc) function at all.  It defines a little nested function to check whether a list does not start with 10 [as the vertex entries do], and applies that to the entity data list, removing all such unwanted entries.  The inverse version also works:

 

(setq ptlst (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel"\Seçim alanını seçiniz !")))))

 

That one looks for entries that do  start with 10, and removes all the others.

 

Yes, it takes a while to get used to how (lambda) functions work in these things, but they can be powerful.

Kent Cooper, AIA
Message 10 of 12

aliozcicek
Contributor
Contributor

Thanks a lot Kent1Cooper,

 

I tried to use both vl-remove-if-not and lamda but couldn't make it work. I was know that command what I need 🙂 I understand some codes really powerfull as you say and I clearly understand I need little more time. but will be fun.

 

thanks for all...

0 Likes
Message 11 of 12

devitg
Advisor
Advisor
Accepted solution
I shall say I do not read all post , but for a SSGET cp or wp, fence , all points SHALL be on screen , or do a Zoom extend
0 Likes
Message 12 of 12

aliozcicek
Contributor
Contributor

yes devitg you right.. this is another key point which I missing... now I understand well why my codes doesn't work anytime. 

 

thanks...

0 Likes