Jump to content

spline from a list


SELFCAD

Recommended Posts

Hi guys,

I have a list with point's coordinates, i want to draw a spline through these points, which is the best way? (or which is the way :) ? Thanks!

Link to comment
Share on other sites

I found this code by google. Seems to replace y with z and z with y for every fit point of a spline. Why?

(setq a (entget (car (entsel "\nSelect SPLine: "))))
 (foreach b a
   (if    (= (car b) 11)
     (setq Pdata
        (append Pdata
            (list (cdr b))
        )
     )
   )
 )

Link to comment
Share on other sites

I'm afraid that that excerpt of code that not replace anything; it only gather all fit points to a list.

 

Regards,

Mircea

Edited by MSasu
Link to comment
Share on other sites

Not sure what your excerpt of code had to do with the UCS - please keep in mind that the points in associated lists are kept in WCS coordinates.

 

By the way, even if the solutions suggested by Lee Mac are far better, a easy way to draw a spline entity from a list of points is:

 

(command "_SPLINE")              ;start the command
(foreach thePoint MyPointsList   ;parse points list
(command thePoint)
)
(command "" "" "")               ;accept default tangents & end the command

 

Regards,

Mircea

Link to comment
Share on other sites

The entmake way, for a list of points lst:

(entmake
      (append
        (list
          '(0 . "SPLINE")
          '(100 . "AcDbEntity")
          '(100 . "AcDbSpline")
          '(70 . 40)
          '(71 . 3)
          (cons 74 (length lst))
          '(44 . 1.0e-005)
          )
        (mapcar '(lambda (x) (cons 11 x)) lst)
        )
      )

Same result as (command "Spline" ...

Link to comment
Share on other sites

if i have a list with points, Pdata, p - a point from Pdata, a fix point px - not from Pdata, and a given value for Distance - let's say 10, can i set a point pd in this way?

 

(if (and (/= (member p Pdata) nil)
    (= (Distance p px) 10))
 (setq pd p))

Link to comment
Share on other sites

So you want to retain a point if he matches simultaneously two conditions: (1) belong to list Pdata and is located at exactly 10 units of a given point px? If true, your code is OK - have made a small correction:

(if (and (member p Pdata)
        (= (Distance p px) 10))
(setq pd p)
)

 

You may test your code parts (unit testing) on Console window of VLisp editor.

 

Regards,

Mircea

Link to comment
Share on other sites

How can i remove the first element from a selection set?

i have:

(setq ss (ssget '((0 . "point"))))

 

and i want to set now something like this:

(setq ss1 (cdr ss)) - this is not possible, but how to do it?

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