Jump to content

Help! Call Lisp vlax-curve-getPointAtDist from VBA


joe2456

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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