joe2456 Posted August 6, 2018 Posted August 6, 2018 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 Quote
joe2456 Posted August 7, 2018 Author Posted August 7, 2018 (edited) 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 August 7, 2018 by SLW210 Code Tags Quote
BIGAL Posted August 7, 2018 Posted August 7, 2018 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))) Quote
joe2456 Posted August 7, 2018 Author Posted August 7, 2018 (edited) 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 August 7, 2018 by SLW210 Code Tags Quote
BIGAL Posted August 7, 2018 Posted August 7, 2018 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 Quote
SLW210 Posted August 7, 2018 Posted August 7, 2018 Please read the Code Posting Guidelines and have your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
Recommended Posts
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.