Jump to content
joe2456

Help! Call Lisp vlax-curve-getPointAtDist from VBA

Recommended Posts

joe2456

Hello Anybody Help.

 

 

I need to get point from spline with use lisp function in autocad vba

 

vlax-curve-getPointAtDist

 

 

Could somebody can help me?

 

 

 

 

Best Regard

Joe

Share this post


Link to post
Share on other sites
joe2456

I write this function but still error on get variable form lisp

 

anybody help!

 

 

 

Function GetPointSpline(oEnt As AcadEntity, distance As Double) As Variant
Dim sVar As Variant
Dim strCom As String
Dim USERR1 As Variant

'sVar = ""
' Call Get Point in spline distance 1.5 from begin point
With ThisDrawing
   .SetVariable "USERR1", 1
   .SendCommand "(vl-load-com)" & vbCr
     strCom = "(setvar " & Chr(34) & "USERR1" & Chr(34) &  Chr(32) & "(vlax-curve-getPointAtDist  (vlax-ename->vla-object  (handent " & Chr(34) & oEnt.Handle & Chr(34) & " )  )"  & " 1.5))" & vbCr
   .SendCommand strCom
   GetPointSpline = .GetVariable("USERR1")
End With
End Function

 

 

Result:

 

; error: AutoCAD variable setting rejected: "USERR1" (-5.97251 -11.4573 0.0)

 

 

 

++++++++++++++++++

How can i get variable value "USERR1" (-5.97251 -11.4573 0.0) in autocad vba?

Edited by SLW210
Code Tags

Share this post


Link to post
Share on other sites
BIGAL

You can not save to USERRx as its a real expects a single number you can save to users1 a string, I would run the lisp as a library function just load and run then get the returned point convert to a VBA variable trying to find example. This way could have a library of the vlax curve stuff.

 

Almost forgot, you need to rewrite the code

; pt=(-5.97251 -11.4573 0.0)
(setq ans (strcat (rtos (car pt) 2 2) " " (rtos (cadr pt) 2 2) "" (rtos (caddr pt) 2 2)))

Share this post


Link to post
Share on other sites
joe2456

SendCommand "(vl-load-com)" & vbCr
     strCom = "(setvar " & Chr(34) & "USERR1" & Chr(34)  &  Chr(32) & "(vlax-curve-getPointAtDist   (vlax-ename->vla-object  (handent " & Chr(34) & oEnt.Handle  & Chr(34) & " )  )"  & " 1.5))" & vbCr
   .SendCommand strCom
   GetPointSpline = .GetVariable("USERR1")

 

 

I just know a little bit lisp code , So How to I get value return string from .Sendcommand strCom.

 

 

 

Thank you.BIGAL

Edited by SLW210
Code Tags

Share this post


Link to post
Share on other sites
BIGAL

Start by breaking down into a 2 step process

Not tested

strCom = "(setvar " & Chr(34) & "USERS1" & Chr(34) & Chr(32) & vbCr)"
.SendCommand strCom
strcom "(setq pt (vlax-curve-getPointAtDist (vlax-ename->vla-object (handent " & Chr(34) & oEnt.Handle & Chr(34) & " ) )" & " 1.5)))" & vbCr
.SendCommand strCom

Share this post


Link to post
Share on other sites
SLW210

Please read the Code Posting Guidelines and have your Code to be included in Code Tags.[NOPARSE]

Your Code Here[/NOPARSE]

=

Your Code Here

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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