Hi,
I have created a string:
strAttValue = ("3/16""=1'-0""")
or alternatively I've tried:
strAttValue = ("3/16" & Chr(34) & "=1'-0" & Chr(34))
that I would like to pass to a lisp with the format:
(defun lispTest ( strAttValue / )
but when I do it errors with "Too many variables." The passing method is as follows:
acDoc.SendStringToExecute("(lispTest" & Chr(34) & strAttValue & Chr(34) & " ) ", True, False, False)
If I get rid of the quotes in the original string it works fine, but the quotes are needed. Does anyone know why this is? How can I make it work?
I really should use VB.NET or C# more often, these simple things kill me and I am sure it is something obvious! - Thanks.
EDIT
Actually, the " symbol is the culprit. If I create:
strAttValue = ("3/16=1'-0")
it works fine, but I need the " symbol to be part of the string so I am stuck. Any ideas?
When I use a (princ strAttValue) using ssomething like strAttValue = ("3/16" & """=1'-0""")
I get the following error:
bad argument type: FILE "=1'-0"
Every Chr(34) have to be replaced with Chr(92) & Chr(34) in order to passed to lisp.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi,
IMO, you'd rather use the Application.Invoke() (A2011 or later), or P/Invoke acedInvoke() (for prior versions) with which you can invoke a LISP function and get its return value.
Your LISP function have to be registered with vl-acad-defun or be prefixed with c:
Here's a little example:
LISP function
(defun lispTest (strArg) (princ (strcat "\nstrArg: " strArg "\n")) strArg ) (vl-acad-defun 'lispTest)
C# code with Application.Invoke():
[CommandMethod("Foo")]
public void Foo() { ResultBuffer args = new ResultBuffer( new TypedValue((int)LispDataType.Text, "lispTest"), new TypedValue((int)LispDataType.Text, "3/16\"=1'-0\"\"")); ResultBuffer retVal = Application.Invoke(args); Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage( "\nretVal:" + retVal.AsArray()[0].Value); }
C# code with P/Invoke acedInvoke:
[System.Security.SuppressUnmanagedCodeSecurity] [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)] extern static private int acedInvoke(IntPtr rbIn, out IntPtr rbOut); public static ResultBuffer InvokeLisp(ResultBuffer args) { IntPtr rb = IntPtr.Zero; int stat = acedInvoke(args.UnmanagedObject, out rb); if (stat == (int)PromptStatus.OK && rb != IntPtr.Zero) return (ResultBuffer)DisposableWrapper.Create(typeof(ResultBuffer), rb, true); return null; } [CommandMethod("Bar")] public void Bar() { ResultBuffer args = new ResultBuffer( new TypedValue((int)LispDataType.Text, "lispTest"), new TypedValue((int)LispDataType.Text, "3/16\"=1'-0\"\"")); ResultBuffer retVal = Application.Invoke(args); Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage( "\nretVal:" + retVal.AsArray()[0].Value); }