Jump to content

how to make a list from a set of points


handasa

Recommended Posts

Greetings everyone

 

i have a set of points

say:

p1 = (x1 , y1 , z1)

p2 = (x2 , y2 , z2)

p3 = (x3 , y3 , z3)

 

when i use

(setq lst (cons p1 lst) )

(setq lst (cons p2 lst) )

(setq lst (cons p3 lst) )

 

the final list will looks like ((x1 y1 z1) (x2 y2 z2) x3 y3 z3)

with the list length is 5 not 3 ... ie the third point is included between parenthesis

 

i usde append instead of "cons" with no hope...

 

any suggestions ?

thanks in advance

Link to comment
Share on other sites

_$ (setq lst (cons '(x1 y1 z1) lst))
((X1 Y1 Z1))
_$ (setq lst (cons '(x2 y2 z2) lst))
((X2 Y2 Z2) (X1 Y1 Z1))
_$ (setq lst (cons '(x3 y3 z3) lst))
((X3 Y3 Z3) (X2 Y2 Z2) (X1 Y1 Z1))

 

Or just wrap them with the list function:

 

_$ (list 
 '(x1 y1 z1)
 '(x2 y2 z2)
 '(x3 y3 z3)
)
((X1 Y1 Z1) (X2 Y2 Z2) (X3 Y3 Z3))

Link to comment
Share on other sites

_$ (setq lst (cons '(x1 y1 z1) lst))
((X1 Y1 Z1))
_$ (setq lst (cons '(x2 y2 z2) lst))
((X2 Y2 Z2) (X1 Y1 Z1))
_$ (setq lst (cons '(x3 y3 z3) lst))
((X3 Y3 Z3) (X2 Y2 Z2) (X1 Y1 Z1))

 

Or just wrap them with the list function:

 

_$ (list 
 '(x1 y1 z1)
 '(x2 y2 z2)
 '(x3 y3 z3)
)
((X1 Y1 Z1) (X2 Y2 Z2) (X3 Y3 Z3))

 

it works well ... thanks..

 

excuse me i have another question and it doesn't worth to open a new thread for it ...

 

...

i have a selection set "ss1"

i want to select among it's entites the ones which intersect with points p1 and p2

 

i tried (setq ssj (ssget "F" (list p1 p4) ) ss1)

but it comes with error message :bad point argument

 

when i use (setq ssj (ssget "F" (list p1 p4) ) ) .. it works well ... but i need only entites from ss1 not all objects...

 

thanks

Link to comment
Share on other sites

i have a selection set "ss1"

i want to select among it's entites the ones which intersect with points p1 and p2

 

i tried (setq ssj (ssget "F" (list p1 p4) ) ss1)

but it comes with error message :bad point argument

 

Reason that you get the error message is that you cannot provide SS as an argument to the ssget function,

Check Lee Mac's tutorial/reference about ssget (the fence example).

 

Quoting from there:

(ssget "_F" '((0 0) (1 1)) '((0 . "LINE")))

 

means..

(ssget "_F" pL ssfL)

Where pL - means point list (list of points)

ssfL - means ssget filter list - assoc list of dotted pairs [optional]

 

So I'd iterate over the "ssj" and exclude using ssmemb the entities that are not in "ss1", grouping them in "newSS":

 

(if
 (and
   (setq ssj (ssget "_F" (list p1 p2 p3 p4))) ; I guess you want the fence through the points, not just the endpoints
   (setq newSS (ssadd)) ; create new empty selection set
 )
 (progn ; iterate over the "ssj" and grip the "newSS"
   (repeat (setq index (sslength ssj))
     (setq ent (ssname ssj (setq index (1- index)))) ; nth entity of the selection set
     (if (ssmemb ent ss1) (ssadd ent newSS)) ; if that entity is inside the "ss1", then collect it in "newSS"
   ); repeat
   (sssetfirst nil newSS) ; grip "newSS"
 ); progn
); if

 

But perfectly only one iteration is enough, if we knew what are the filter criterias for "ss1".

Link to comment
Share on other sites

Reason that you get the error message is that you cannot provide SS as an argument to the ssget function,

Check Lee Mac's tutorial/reference about ssget (the fence example).

 

Quoting from there:

 

 

means..

(ssget "_F" pL ssfL)

Where pL - means point list (list of points)

ssfL - means ssget filter list - assoc list of dotted pairs [optional]

 

So I'd iterate over the "ssj" and exclude using ssmemb the entities that are not in "ss1", grouping them in "newSS":

 

(if
 (and
   (setq ssj (ssget "_F" (list p1 p2 p3 p4))) ; I guess you want the fence through the points, not just the endpoints
   (setq newSS (ssadd)) ; create new empty selection set
 )
 (progn ; iterate over the "ssj" and grip the "newSS"
   (repeat (setq index (sslength ssj))
     (setq ent (ssname ssj (setq index (1- index)))) ; nth entity of the selection set
     (if (ssmemb ent ss1) (ssadd ent newSS)) ; if that entity is inside the "ss1", then collect it in "newSS"
   ); repeat
   (sssetfirst nil newSS) ; grip "newSS"
 ); progn
); if

 

But perfectly only one iteration is enough, if we knew what are the filter criterias for "ss1".

 

.. thanks a lot for your time and good explanation ....the ss1 are only of the type "line" if this make a different

Link to comment
Share on other sites

....the ss1 are only of the type "line" if this make a different

 

Then you could just do this:

 

(sssetfirst nil (ssget "_F" (list p1 p2 p3 p4) '((0 . "LINE"))))

 

Ofcourse if you intend only to "grip" the selection set.

Link to comment
Share on other sites

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