Problem with vlisp spline tangent syntax

Problem with vlisp spline tangent syntax

leeminardi
Mentor Mentor
525 Views
4 Replies
Message 1 of 5

Problem with vlisp spline tangent syntax

leeminardi
Mentor
Mentor

I am having a problem getting vlisp to accept tangent conditions for the creation of a spline.  For example,  given the following:

leeminardi_1-1694890071361.png

I would like to reference the 5 points in a vlisp command.

To create the spline interactively in AutoCAD you would input 

spline

point 1

t (tangent)

point 4

point 2

point 3

t

point 5

resulting in the spline shown.

In vlisp I would expect the following to work but it throws and error for the "t".

 

(defun c:test (/)
  (setq	p1 (getpoint "\nPick point #1: ")
	p2 (getpoint "\nPick point #2: ")
	p3 (getpoint "\nPick point #3: ")
	p4 (getpoint "\nPick point #4: ")
	p5 (getpoint "\nPick point #5: ")
  )
  (command "_spline" p1 "t" p4 p2 p3 "t" p5 )
  (princ)
)

 

How can I specify tangent conditions for creating a spline with vlisp.

 

On a related note,  I tried using 5 points and the spline CV method for creating a spline.  But even if the spline command includes "m" " cv" to specify CV method the command it still assumes the fit method.

E.g.,

(command "_spline" "m" "CV" p1 p4 p2 p5 p3) 

lee.minardi
0 Likes
Accepted solutions (2)
526 Views
4 Replies
Replies (4)
Message 2 of 5

paullimapa
Mentor
Mentor
Accepted solution

try this:

(defun c:test (/)
  (setq	p1 (getpoint "\nPick point #1: ")
	p2 (getpoint "\nPick point #2: ")
	p3 (getpoint "\nPick point #3: ")
	p4 (getpoint "\nPick point #4: ")
	p5 (getpoint "\nPick point #5: ")
  )
  (vla-Sendcommand(vla-Get-ActiveDocument(vlax-Get-Acad-Object))"_.Spline !p1 _T !p4 !p2 !p3 _T !p5\n")
  (princ)
)

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

This is another case where the command operates differently inside an AutoLisp (command) function than it does manually at the Command line.  It's using a sort of "native" "core" "underlying" older version of the command operation.  But you can force it to operate like the current manually-drawn version -- just add one line [read about it in the AutoLisp Reference]:

  ....

    p5 (getpoint "\nPick point #5: ")
  )
  (initcommandversion)
  (command "_spline" ....

Kent Cooper, AIA
0 Likes
Message 4 of 5

leeminardi
Mentor
Mentor

@paullimapa and @Kent1Cooper thank you both for your responses.  I think I will go with Kent's "initicommandversion" as it allows me to use the spline command in a manner to which I am accustomed.  It was easy for me to make it use CV rather than fit points and tangents.  E.g.,

   

  (initcommandversion)
  (command "_spline" "m" "cv" p1 p2 p3 p4 p5)

 Thanks again.

Lee

lee.minardi
0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

Triggered by another topic we both participated in, also about Splines, I will suggest that you can use it without (initcommandversion) if you let it use its old/native/underlying operation, where both tangencies are asked for at the end of the command, instead of the start tangency being defined right after the first point.  That would require your point 4 to be below point 1, since the tangency directions are both in the away-from-the-end directions.

 

A meaningful difference:  It seems that in the current operation, used in your image, point 4 does not merely define the tangent direction from point 1, but the distance from point 1 to point 4 has a "pull" effect and a great impact on the resulting shape:

Kent1Cooper_0-1694984424909.png

Here, points 1, 2, 3 & 5 are the same in both, but the red point 4 results in the red Spline, and the green point 4 in the green Spline.  In the old/native/underlying operation, however, with your point 4 below point 1, it does define only the direction of tangency, and how far away it is doesn't seem to make any difference.

Kent Cooper, AIA
0 Likes