joe2456 发表于 2022-7-6 21:47:08

Help! Call Lisp vlax-curve-get

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

joe2456 发表于 2022-7-6 22:01:22

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

Function GetPointSpline(oEnt As AcadEntity, distance As Double) As VariantDim sVar As VariantDim strCom As StringDim USERR1 As Variant'sVar = ""' Call Get Point in spline distance 1.5 from begin pointWith 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 WithEnd 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?

BIGAL 发表于 2022-7-6 22:17:05

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

joe2456 发表于 2022-7-6 22:30:56

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

BIGAL 发表于 2022-7-6 22:45:01

Start by breaking down into a 2 step process
Not tested

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

SLW210 发表于 2022-7-6 22:51:20

Please read the Code Posting Guidelines and have your Code to be included in Code Tags.
Your Code Here =
Your Code Here
页: [1]
查看完整版本: Help! Call Lisp vlax-curve-get