.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

prompting the user to pick a point(s) and draw a line using lisp in .net

7 REPLIES 7
Reply
Message 1 of 8
devulapally_vijay
866 Views, 7 Replies

prompting the user to pick a point(s) and draw a line using lisp in .net

hi

i m using .net form,Autocad and lisp
to generate a drawing

First i prompt user to pick a starting point and then i show dialog box developed in .net , if user clicks on conitnue button in dialog box
and next i prompt the user to enter the ending point

now basing on the starting point and ending point , i generate a drawing using lisp program
i pass these two points to lisp function command as a input

then it will generate a drawing (some rectangles,plines,text etc)

this process should stop while user clicks end button in dialog box

here is my code

_
Public Sub HelloCommand()
AcadDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("(LOAD " & Chr(34) + "c:/LispSld/myline.lsp" & Chr(34) & " )" & vbCr, True, False, True)
PointArryListX = New ArrayList
PointArryListY = New ArrayList
Dim plp As String = ""
Dim f As dotnetApp.Form1
Dim askpoint As Boolean = True

While True
f = New dotnetApp.Form1
dotnetApp.myClass1.pLoop = ""
plp = ""
Dim myDB As Database
Dim myEd As Editor
Dim myPEO As Autodesk.AutoCAD.EditorInput.PromptPointOptions
myDB = AcadDoc.Database
myEd = AcadDoc.Editor
myPEO = New Autodesk.AutoCAD.EditorInput.PromptPointOptions(vbLf & "Select a dvk Point " + (PointArryListX.Count + 1).ToString() + ":")
myPEO.AllowNone = True
myPEO.UseBasePoint = False
Dim myPER As Autodesk.AutoCAD.EditorInput.PromptPointResult
Dim myPS As Autodesk.AutoCAD.EditorInput.PromptStatus
myPER = myEd.GetPoint(myPEO)
myPS = myPER.Status
Select Case myPS
Case Autodesk.AutoCAD.EditorInput.PromptStatus.OK
Dim picked As Point3d = myPER.Value
PointArryListX.Add(picked.X.ToString())
PointArryListY.Add(picked.Y.ToString())
MessageBox.Show("U picked a pt")
Case Autodesk.AutoCAD.EditorInput.PromptStatus.Cancel
MsgBox("You cancelled.")
Exit Sub
Case Autodesk.AutoCAD.EditorInput.PromptStatus.Error
MsgBox("Error warning.")
Exit Sub
Case Else
MessageBox.Show("not picked a pt")
Exit Sub
End Select
f.ShowDialog()
plp = dotnetApp.myClass1.pLoop
If plp = "y" Then
Series = dotnetApp.myClass1.txtSeries
Tag = dotnetApp.myClass1.txtTag
Width = dotnetApp.myClass1.txtWidth
Thick = dotnetApp.myClass1.txtThick
Height = dotnetApp.myClass1.txtHeight
Else
Exit While
End If
If PointArryListX.Count > 1 Then
Dim cnt As Integer
cnt = PointArryListX.Count
Dim cmd As String = " "
cmd = cmd + "_ca" + vbCr
cmd = cmd + PointArryListX.Item(cnt - 2) + vbCr
cmd = cmd + PointArryListY.Item(cnt - 2) + vbCr
cmd = cmd + PointArryListX.Item(cnt - 1) + vbCr
cmd = cmd + PointArryListY.Item(cnt - 1) + vbCr
cmd = cmd + Series + vbCr
cmd = cmd + Tag + vbCr
cmd = cmd + Width + vbCr
cmd = cmd + Thick + vbCr
cmd = cmd + Height + vbCr
cmd = cmd + "Ladder" + vbCr
cmd = cmd + "Tray_Type" + vbCr
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute(cmd, True, False, True)
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("n" + vbCr, True, False, True)
End If
End While


my problem is
after selecting two points if i press on continue then the drawing is not generated
if press end then the drawing is generated

my requirement is
step1)prompt the user to pick the point
step2)show the dialog box and user enter all the details and clicks on conitnue
step3)prompt the user to pick the point
step4)show the dialog box and user enter all the details and clicks on conitnue
and a drawing is generated using the first two points

but this is not happening, this happens only if user clicks on end button and when the dialog box is closed

please help me
7 REPLIES 7
Message 2 of 8

Without fully testing the code, one thing I've identified is the use of vbCr (Carriage return). Most strings I've sent to execute use the typical space (" ") unless the prompt is for an actual string.

Another thing to try might be sending separate strings rather than building on the cmd.

{code}
Public Sub HelloCommand()
AcadDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("(LOAD " & Chr(34) + "c:/LispSld/myline.lsp" & Chr(34) & " )" & vbCr, True, False, True)
PointArryListX = New ArrayList
PointArryListY = New ArrayList
Dim plp As String = ""
Dim f As dotnetApp.Form1
Dim askpoint As Boolean = True

While True
f = New dotnetApp.Form1
dotnetApp.myClass1.pLoop = ""
plp = ""
Dim myDB As Database
Dim myEd As Editor
Dim myPEO As Autodesk.AutoCAD.EditorInput.PromptPointOptions
myDB = AcadDoc.Database
myEd = AcadDoc.Editor

myPEO = New Autodesk.AutoCAD.EditorInput.PromptPointOptions(vbLf & "Select a dvk Point " + (PointArryListX.Count + 1).ToString() + ":")
myPEO.AllowNone = True
myPEO.UseBasePoint = False

Dim myPER As Autodesk.AutoCAD.EditorInput.PromptPointResult
Dim myPS As Autodesk.AutoCAD.EditorInput.PromptStatus
myPER = myEd.GetPoint(myPEO)
myPS = myPER.Status

Select Case myPS
Case Autodesk.AutoCAD.EditorInput.PromptStatus.OK
Dim picked As Point3d = myPER.Value
PointArryListX.Add(picked.X.ToString())
PointArryListY.Add(picked.Y.ToString())
MessageBox.Show("U picked a pt")
Case Autodesk.AutoCAD.EditorInput.PromptStatus.Cancel
MsgBox("You cancelled.")
Exit Sub
Case Autodesk.AutoCAD.EditorInput.PromptStatus.Error
MsgBox("Error warning.")
Exit Sub
Case Else
MessageBox.Show("not picked a pt")
Exit Sub
End Select

f.ShowDialog()
plp = dotnetApp.myClass1.pLoop
If plp = "y" Then
Series = dotnetApp.myClass1.txtSeries
Tag = dotnetApp.myClass1.txtTag
Width = dotnetApp.myClass1.txtWidth
Thick = dotnetApp.myClass1.txtThick
Height = dotnetApp.myClass1.txtHeight
Else
Exit While
End If

If PointArryListX.Count > 1 Then
Dim cnt As Integer
cnt = PointArryListX.Count
Dim cmd As String = ""
cmd = cmd + "_ca "
cmd = cmd + PointArryListX.Item(cnt - 2) + " "
cmd = cmd + PointArryListY.Item(cnt - 2) + " "
cmd = cmd + PointArryListX.Item(cnt - 1) + " "
cmd = cmd + PointArryListY.Item(cnt - 1) + " "
cmd = cmd + Series + " "
cmd = cmd + Tag + " "
cmd = cmd + Width + " "
cmd = cmd + Thick + " "
cmd = cmd + Height + " "
cmd = cmd + "Ladder" + " "
cmd = cmd + "Tray_Type" + " "
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute(cmd, True, False, True)
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("n" + vbCr, True, False, True)
End If
End While
{code}
Message 3 of 8

hi

thanks for ur reply

i replaced the carriage return with single space
but the same problem occurred.

now i removed the dialoag box and tested even though the same problem is happening

acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("(LOAD " & Chr(34) + "c:/LispSld/myline.lsp" & Chr(34) & " )" & vbCr, True, False, True)

after this execution of statement i found that
auto cad command prompt is like this :

select a dvk point 1: Load c:/lispsld/myline.lsp

for every command statement the command prompt is showing
"select a dvk point ":

i load the lisp file at th begining of the command function

after that i wrote


Autodesk.AutoCAD.EditorInput.PromptPointOptions(vbLf & "Select a dvk Point " + (PointArryListX.Count + 1).ToString() + ":")

what is effect of this statement

suppose if i send a hello msg then it prompts "Select a dvk Point"

please help me
Message 4 of 8
Anonymous
in reply to: devulapally_vijay

Your code is unreadable in my newsreader, so I can't help.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6298522@discussion.autodesk.com...
hi i m using .net form,Autocad and lisp to generate a drawing First i prompt
user to pick a starting point and then i show dialog box developed in .net ,
if user clicks on conitnue button in dialog box and next i prompt the user
to enter the ending point now basing on the starting point and ending point
, i generate a drawing using lisp program i pass these two points to lisp
function command as a input then it will generate a drawing (some
rectangles,plines,text etc) this process should stop while user clicks end
button in dialog box here is my code _ Public Sub HelloCommand() AcadDoc =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("(LOAD " &
Chr(34) + "c:/LispSld/myline.lsp" & Chr(34) & " )" & vbCr, True, False,
True) PointArryListX = New ArrayList PointArryListY = New ArrayList Dim plp
As String = "" Dim f As dotnetApp.Form1 Dim askpoint As Boolean = True While
True f = New dotnetApp.Form1 dotnetApp.myClass1.pLoop = "" plp = "" Dim myDB
As Database Dim myEd As Editor Dim myPEO As
Autodesk.AutoCAD.EditorInput.PromptPointOptions myDB = AcadDoc.Database myEd
= AcadDoc.Editor myPEO = New
Autodesk.AutoCAD.EditorInput.PromptPointOptions(vbLf & "Select a dvk Point "
+ (PointArryListX.Count + 1).ToString() + ":") myPEO.AllowNone = True
myPEO.UseBasePoint = False Dim myPER As
Autodesk.AutoCAD.EditorInput.PromptPointResult Dim myPS As
Autodesk.AutoCAD.EditorInput.PromptStatus myPER = myEd.GetPoint(myPEO) myPS
= myPER.Status Select Case myPS Case
Autodesk.AutoCAD.EditorInput.PromptStatus.OK Dim picked As Point3d =
myPER.Value PointArryListX.Add(picked.X.ToString())
PointArryListY.Add(picked.Y.ToString()) MessageBox.Show("U picked a pt")
Case Autodesk.AutoCAD.EditorInput.PromptStatus.Cancel MsgBox("You
cancelled.") Exit Sub Case Autodesk.AutoCAD.EditorInput.PromptStatus.Error
MsgBox("Error warning.") Exit Sub Case Else MessageBox.Show("not picked a
pt") Exit Sub End Select f.ShowDialog() plp = dotnetApp.myClass1.pLoop If
plp = "y" Then Series = dotnetApp.myClass1.txtSeries Tag =
dotnetApp.myClass1.txtTag Width = dotnetApp.myClass1.txtWidth Thick =
dotnetApp.myClass1.txtThick Height = dotnetApp.myClass1.txtHeight Else Exit
While End If If PointArryListX.Count > 1 Then Dim cnt As Integer cnt =
PointArryListX.Count Dim cmd As String = " " cmd = cmd + "_ca" + vbCr cmd =
cmd + PointArryListX.Item(cnt - 2) + vbCr cmd = cmd +
PointArryListY.Item(cnt - 2) + vbCr cmd = cmd + PointArryListX.Item(cnt - 1)
+ vbCr cmd = cmd + PointArryListY.Item(cnt - 1) + vbCr cmd = cmd + Series +
vbCr cmd = cmd + Tag + vbCr cmd = cmd + Width + vbCr cmd = cmd + Thick +
vbCr cmd = cmd + Height + vbCr cmd = cmd + "Ladder" + vbCr cmd = cmd +
"Tray_Type" + vbCr
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute(cmd, True,
False, True)
acadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("n" + vbCr,
True, False, True) End If End While my problem is after selecting two points
if i press on continue then the drawing is not generated if press end then
the drawing is generated my requirement is step1)prompt the user to pick the
point step2)show the dialog box and user enter all the details and clicks on
conitnue step3)prompt the user to pick the point step4)show the dialog box
and user enter all the details and clicks on conitnue and a drawing is
generated using the first two points but this is not happening, this happens
only if user clicks on end button and when the dialog box is closed please
help me
Message 5 of 8

hi

no problem
i attached code to this post please find it Edited by: devulapally_vijay on Dec 4, 2009 11:24 AM
Message 6 of 8
Anonymous
in reply to: devulapally_vijay

Your approach to using .NET with LISP isn't going to work.

You should implement your application in LISP, and use .NET only for the
user interface (call a LispFunction to show your user interface, and have it
return the required input, and do the work in LISP).

If you have other things that can't be done in LISP, and have to use .NET
for them, you should implement LispFunctions that can be called from LISP to
do the work.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6299353@discussion.autodesk.com...
hi

no problem
i attached code to this post please find it

Edited by: devulapally_vijay on Dec 4, 2009 11:24 AM
Message 7 of 8

hi

Thanks for your reply

can you explain me with a small example or article

bcoz i could not understood your answer

Thanks in advance
Message 8 of 8
Anonymous
in reply to: devulapally_vijay

Sorry, this isn't an online classroom where participants have time to
provide you with custom code samples. We don't work for Autodesk.

Visit Autodesk's website and download the tutorials, the ADN presentations,
and see the online docs. Look for examples and docs on using the
'LispFunction' attribute to expose .NET functionality to LISP.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6301600@discussion.autodesk.com...
hi

Thanks for your reply

can you explain me with a small example or article

bcoz i could not understood your answer

Thanks in advance

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost