Draw Spline, many point user input.

Draw Spline, many point user input.

aliff_ahtenk
Enthusiast Enthusiast
2,018 Views
4 Replies
Message 1 of 5

Draw Spline, many point user input.

aliff_ahtenk
Enthusiast
Enthusiast

Hai all,

 

i would like to make a lisp that can let user draw a spline. after finish draw, it can ask weather want to adjust or not, if not, i would like it to proceed to make others things. that all. suppose the spline need to be tangent to first and last point or people around call it parrallel to the insertion point. first point is predefine which, it continues from my previous lisp program.

 

the goal is to draw spline,

if user dont need to change,

proceed to do something else.

 

I wish to use normal spline command, which user will press enter or spacebar to end command, coz normally we use spline, around 3 to 9 point, but some time it will be more than that.

Then adjust some point, if no adjustment, we use other lisp to finish the work.

 

Thanks in advance..

0 Likes
Accepted solutions (1)
2,019 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here is some example of how to allow multiple user inputs, no matter how many.

 

(defun c:DrawSpline ()

  (initcommandversion)
  (command "_.spline")
  (while (> (getvar 'cmdactive) 0) (command pause))
  (initget "Edit")
  (if (getkword "\nNow you have the opportunity to make a major decision. Do you want to [Edit] the spline or : ")
    (progn
      (command "_.splinedit" "_last")
      (while (> (getvar 'cmdactive) 0) (command pause))))
  (c:other-list-that-will-finish-the-work)
  (princ)
  )

(defun c:other-list-that-will-finish-the-work () (princ "Work done.") (princ))

 

BUT Edits are an issue. The above code uses the SPLINEDIT command. Not sure if you had this command in mind... more likely you meant GRIP_EDITS which are significantly more friendly to use. But AFAIK... this can't be run within LISP.

 

I would suggest leaving the routine for edits... then re-run the routine and proceed with <last> entity.

0 Likes
Message 3 of 5

leeminardi
Mentor
Mentor

If one of your goals is to be able to adjust the slope (tangency) of the spline at its ends I suggest you get comfortable using the Control Vertices method of editing a spline.  You can do this be turning on the CVs by changing the method property to Control Vertex or through the use of splinedit. You control the spline slope at its ends by moving the second CV or next-to-the-last CV of the spline. The vector from the first to the second CV defines the slope while the distance between these two CVs defines the instantaneous radius of curvature for the spline at its start. To create a sharp bend in a spline make  "n" consecutive CVs coincident where "n" is the degree of the spline (typically 3 by default).  Working with CVs gives you great control of a spline!

 

Note, editing a spline by moving the second and next-to-the-last CV provides a similar interface to that found in other CAD programs such as Inventor, 3ds Max, and even Power Point, that use "handles" to edit splines.

lee.minardi
0 Likes
Message 4 of 5

aliff_ahtenk
Enthusiast
Enthusiast

your code work bro.. but need to rearrange some missing code..

i just thought that if we can pause it when editing the point location, it would be great.. but somehow it will be hard to control.

 

(command "_.splinedit" "F" "M" "S" Pt)

i dont know how, but if user get stay in loop until they press enter, then it finish, the code should great..

0 Likes
Message 5 of 5

ВeekeeCZ
Consultant
Consultant

Try this.

 

  (initcommandversion)
  (command "_.splinedit" "_last" "F" "M")
  (while (setq pnt (getpoint "\nPick a point to edit <done>: "))
  (command "S" "_non" pnt pause))
  (command "exit" "exit" "exit")

 

0 Likes