Sendcommand Select Object

Sendcommand Select Object

Anonymous
Not applicable
1,163 Views
7 Replies
Message 1 of 8

Sendcommand Select Object

Anonymous
Not applicable
I am using the following code to try and run a command and have it use a 3dpolyline that gets selected by the user. The problem is at the handent part of the code. How would I have the sendcommand use that 3dpoly? I have to use the sendcommand because the 3D Polyline Create Curb command can not be accessed any other way (as far as I know). Dim ent As Object Dim pt As Variant Dim Cmd1 As String Dim Cmd2 As String Dim Cmd3 As String Cmd1 = "(er_mnl)" Cmd2 = "(zz_sdsk'(er_grdcurb))" Cmd3 = "ldd" On Error Resume Next ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets selected here If (Err.Number = 0) Then ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & "(handent """ & ent.Handle & """)" Else 'The user didn't pick something End If Thanks for any help, Jason
0 Likes
1,164 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Here's one I wrote that's self explanitory. Public Function Ent2lspEnt(entObj As AcadEntity) As String 'Designed to work with SendCommand, which can't pass objects. 'This gets an objects handle and converts it to a string 'of lisp commands that returns an entity name when run in SendCommand. Dim entHandle As String entHandle = entObj.Handle Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")" End Function -- -- Ed -- "Jason Stevens" wrote in message news:403e2ea0_2@newsprd01... > I am using the following code to try and run a command and have it use a > 3dpolyline that gets selected by the user. The problem is at the handent > part of the code. How would I have the sendcommand use that 3dpoly? I have > to use the sendcommand because the 3D Polyline Create Curb command can not > be accessed any other way (as far as I know). > > Dim ent As Object > Dim pt As Variant > Dim Cmd1 As String > Dim Cmd2 As String > Dim Cmd3 As String > > Cmd1 = "(er_mnl)" > Cmd2 = "(zz_sdsk'(er_grdcurb))" > Cmd3 = "ldd" > > On Error Resume Next > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > selected here > If (Err.Number = 0) Then > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > "(handent """ & ent.Handle & """)" > Else > 'The user didn't pick something > End If > > > Thanks for any help, > Jason > >
0 Likes
Message 3 of 8

Anonymous
Not applicable
Jason, Instead of using Sendcommand, which processes asynchrously with the remaining code, why noy create your own curb function? I've created this as a start for you, no error checking and it may/probably will fail if the offset function truncates the pline but it should give you the basics.... Option Explicit Sub TestMe() Dim ent As Object Dim Pline As Acad3DPolyline Dim newPline As Acad3DPolyline Dim pt As Variant Dim curbHeight As Double Dim curbOffset As Double On Error Resume Next ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets selected here If (Err.Number = 0) Then If TypeOf ent Is Acad3DPolyline Then Set Pline = ent curbHeight = ThisDrawing.Utility.GetReal(vbCrLf & "Curb height: ") curbOffset = ThisDrawing.Utility.GetReal(vbCrLf & "Offset distance: ") Set newPline = MakeCurb(Pline, curbHeight, curbOffset) End If Else 'The user didn't pick something End If End Sub Public Function MakeCurb(Pline As Acad3DPolyline, height As Double, offset As Double) As Acad3DPolyline Dim tempPline1 As AcadPolyline Dim tempPline2 As AcadPolyline Dim newPline As Acad3DPolyline Dim temp As Variant Dim coords As Variant Dim newcoords As Variant Dim i As Long coords = Pline.Coordinates If offset <> 0 Then Set tempPline1 = ThisDrawing.ModelSpace.AddPolyline(coords) temp = tempPline1.offset(offset) Set tempPline2 = temp(0) newcoords = tempPline2.Coordinates tempPline1.Delete tempPline2.Delete Else newcoords = coords End If For i = 2 To UBound(newcoords) Step 3 newcoords(i) = coords(i) + height Next i Set newPline = ThisDrawing.ModelSpace.Add3DPoly(newcoords) newPline.Layer = Pline.Layer Set MakeCurb = newPline End Function HTH, Jeff "Jason Stevens" wrote in message news:403e2ea0_2@newsprd01... > I am using the following code to try and run a command and have it use a > 3dpolyline that gets selected by the user. The problem is at the handent > part of the code. How would I have the sendcommand use that 3dpoly? I have > to use the sendcommand because the 3D Polyline Create Curb command can not > be accessed any other way (as far as I know). > > Dim ent As Object > Dim pt As Variant > Dim Cmd1 As String > Dim Cmd2 As String > Dim Cmd3 As String > > Cmd1 = "(er_mnl)" > Cmd2 = "(zz_sdsk'(er_grdcurb))" > Cmd3 = "ldd" > > On Error Resume Next > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > selected here > If (Err.Number = 0) Then > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > "(handent """ & ent.Handle & """)" > Else > 'The user didn't pick something > End If > > > Thanks for any help, > Jason > >
0 Likes
Message 4 of 8

Anonymous
Not applicable
Ed, I implemented your code but am still having a problem. My code currently looks like: Dim Ent As AcadEntity Dim pt As Variant Dim Cmd1 As String Dim Cmd2 As String Dim Cmd3 As String Dim entHandle As String Dim Ent21spEnt As String Cmd1 = "(er_mnl)" Cmd2 = "(zz_sdsk'(er_grdcurb))" Cmd3 = "ldd" On Error Resume Next ThisDrawing.Utility.GetEntity Ent, pt, "Pick something:" entHandle = Ent.Handle Ent21spEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")" If (Err.Number = 0) Then ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & Ent21spEnt & vbCr Else 'The user didn't pick something End If I get this (handent "A22A") at the select polyline step and then it says: Can't reenter LISP Invalid point It then asks to Select polyline again. Any ideas why it is not working? I did try placing the code in its own module and calling to that way but got the same results. Jason "Ed Jobe" wrote in message news:403e37f4$1_3@newsprd01... > Here's one I wrote that's self explanitory. > > Public Function Ent2lspEnt(entObj As AcadEntity) As String > 'Designed to work with SendCommand, which can't pass objects. > 'This gets an objects handle and converts it to a string > 'of lisp commands that returns an entity name when run in SendCommand. > Dim entHandle As String > > entHandle = entObj.Handle > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")" > End Function > > -- > -- > Ed > -- > "Jason Stevens" wrote in message > news:403e2ea0_2@newsprd01... > > I am using the following code to try and run a command and have it use a > > 3dpolyline that gets selected by the user. The problem is at the handent > > part of the code. How would I have the sendcommand use that 3dpoly? I > have > > to use the sendcommand because the 3D Polyline Create Curb command can not > > be accessed any other way (as far as I know). > > > > Dim ent As Object > > Dim pt As Variant > > Dim Cmd1 As String > > Dim Cmd2 As String > > Dim Cmd3 As String > > > > Cmd1 = "(er_mnl)" > > Cmd2 = "(zz_sdsk'(er_grdcurb))" > > Cmd3 = "ldd" > > > > On Error Resume Next > > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > > selected here > > If (Err.Number = 0) Then > > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > > "(handent """ & ent.Handle & """)" > > Else > > 'The user didn't pick something > > End If > > > > > > Thanks for any help, > > Jason > > > > > >
0 Likes
Message 5 of 8

Anonymous
Not applicable
Jason, I don't have Land or whatever so I can't check your functions, but if you haven't already you should check your commands incrementally. Truncate your command string (save a copy first, of course), and put an "End" statement after it, and see if your code leaves you hanging in the middle of the command where you expect to be. Add a little more of your command string and re-run. Sometimes it's just a matter of the wrong # of vbCR's or something... or the command may require a varying # of CR's. HTH, James
0 Likes
Message 6 of 8

Anonymous
Not applicable
Jeff, That is awesome. Thank you very much. I am going to have it offset 5 times so I just have to do that part but this is great. Thanks, Jason "Jeff Mishler" wrote in message news:403e495e_2@newsprd01... > Jason, > Instead of using Sendcommand, which processes asynchrously with the > remaining code, why noy create your own curb function? I've created this as > a start for you, no error checking and it may/probably will fail if the > offset function truncates the pline but it should give you the basics.... > > Option Explicit > > Sub TestMe() > Dim ent As Object > Dim Pline As Acad3DPolyline > Dim newPline As Acad3DPolyline > Dim pt As Variant > Dim curbHeight As Double > Dim curbOffset As Double > > On Error Resume Next > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > selected here > If (Err.Number = 0) Then > If TypeOf ent Is Acad3DPolyline Then > Set Pline = ent > curbHeight = ThisDrawing.Utility.GetReal(vbCrLf & "Curb height: ") > curbOffset = ThisDrawing.Utility.GetReal(vbCrLf & "Offset distance: > ") > Set newPline = MakeCurb(Pline, curbHeight, curbOffset) > End If > Else > 'The user didn't pick something > End If > > End Sub > > Public Function MakeCurb(Pline As Acad3DPolyline, height As Double, offset > As Double) As Acad3DPolyline > Dim tempPline1 As AcadPolyline > Dim tempPline2 As AcadPolyline > Dim newPline As Acad3DPolyline > Dim temp As Variant > Dim coords As Variant > Dim newcoords As Variant > Dim i As Long > > coords = Pline.Coordinates > If offset <> 0 Then > Set tempPline1 = ThisDrawing.ModelSpace.AddPolyline(coords) > temp = tempPline1.offset(offset) > Set tempPline2 = temp(0) > newcoords = tempPline2.Coordinates > tempPline1.Delete > tempPline2.Delete > Else > newcoords = coords > End If > For i = 2 To UBound(newcoords) Step 3 > newcoords(i) = coords(i) + height > Next i > Set newPline = ThisDrawing.ModelSpace.Add3DPoly(newcoords) > newPline.Layer = Pline.Layer > Set MakeCurb = newPline > > End Function > > HTH, > Jeff > > > "Jason Stevens" wrote in message > news:403e2ea0_2@newsprd01... > > I am using the following code to try and run a command and have it use a > > 3dpolyline that gets selected by the user. The problem is at the handent > > part of the code. How would I have the sendcommand use that 3dpoly? I > have > > to use the sendcommand because the 3D Polyline Create Curb command can not > > be accessed any other way (as far as I know). > > > > Dim ent As Object > > Dim pt As Variant > > Dim Cmd1 As String > > Dim Cmd2 As String > > Dim Cmd3 As String > > > > Cmd1 = "(er_mnl)" > > Cmd2 = "(zz_sdsk'(er_grdcurb))" > > Cmd3 = "ldd" > > > > On Error Resume Next > > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > > selected here > > If (Err.Number = 0) Then > > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > > "(handent """ & ent.Handle & """)" > > Else > > 'The user didn't pick something > > End If > > > > > > Thanks for any help, > > Jason > > > > > >
0 Likes
Message 7 of 8

Anonymous
Not applicable
Ent2LispEnt is a funtion, not a variable. You should have just pasted the code into your module. Ent2LispEnt(Ent) returns a string with the handle in it. I don't know what those other lisp funtions do, but try setting a lisp var first, and then calling the other funtions with them referencing the variable you just set. -- -- Ed -- "Jason Stevens" wrote in message news:403e4dea_2@newsprd01... > Ed, > I implemented your code but am still having a problem. My code currently > looks like: > > Dim Ent As AcadEntity > Dim pt As Variant > Dim Cmd1 As String > Dim Cmd2 As String > Dim Cmd3 As String > Dim entHandle As String > Dim Ent21spEnt As String > > Cmd1 = "(er_mnl)" > Cmd2 = "(zz_sdsk'(er_grdcurb))" > Cmd3 = "ldd" > > On Error Resume Next > ThisDrawing.Utility.GetEntity Ent, pt, "Pick something:" > entHandle = Ent.Handle > Ent21spEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")" > If (Err.Number = 0) Then > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > Ent21spEnt & vbCr > Else > 'The user didn't pick something > End If > > I get this (handent "A22A") at the select polyline step and then it says: > Can't reenter LISP > Invalid point > It then asks to Select polyline again. Any ideas why it is not working? I > did try placing the code in its own module and calling to that way but got > the same results. > > Jason > > > "Ed Jobe" wrote in message > news:403e37f4$1_3@newsprd01... > > Here's one I wrote that's self explanitory. > > > > Public Function Ent2lspEnt(entObj As AcadEntity) As String > > 'Designed to work with SendCommand, which can't pass objects. > > 'This gets an objects handle and converts it to a string > > 'of lisp commands that returns an entity name when run in SendCommand. > > Dim entHandle As String > > > > entHandle = entObj.Handle > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")" > > End Function > > > > -- > > -- > > Ed > > -- > > "Jason Stevens" wrote in message > > news:403e2ea0_2@newsprd01... > > > I am using the following code to try and run a command and have it use a > > > 3dpolyline that gets selected by the user. The problem is at the handent > > > part of the code. How would I have the sendcommand use that 3dpoly? I > > have > > > to use the sendcommand because the 3D Polyline Create Curb command can > not > > > be accessed any other way (as far as I know). > > > > > > Dim ent As Object > > > Dim pt As Variant > > > Dim Cmd1 As String > > > Dim Cmd2 As String > > > Dim Cmd3 As String > > > > > > Cmd1 = "(er_mnl)" > > > Cmd2 = "(zz_sdsk'(er_grdcurb))" > > > Cmd3 = "ldd" > > > > > > On Error Resume Next > > > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > > > selected here > > > If (Err.Number = 0) Then > > > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > > > "(handent """ & ent.Handle & """)" > > > Else > > > 'The user didn't pick something > > > End If > > > > > > > > > Thanks for any help, > > > Jason > > > > > > > > > > > >
0 Likes
Message 8 of 8

Anonymous
Not applicable
You are welcome and I'm glad you like it. I'd been thinking about doing that for some time, and your initial post made me think about it again. So thanks to you for prodding me on! ;-) Jeff "Jason Stevens" wrote in message news:403e5408$1_2@newsprd01... > Jeff, > That is awesome. Thank you very much. I am going to have it offset 5 times > so I just have to do that part but this is great. > > Thanks, > Jason > > "Jeff Mishler" wrote in message > news:403e495e_2@newsprd01... > > Jason, > > Instead of using Sendcommand, which processes asynchrously with the > > remaining code, why noy create your own curb function? I've created this > as > > a start for you, no error checking and it may/probably will fail if the > > offset function truncates the pline but it should give you the basics.... > > > > Option Explicit > > > > Sub TestMe() > > Dim ent As Object > > Dim Pline As Acad3DPolyline > > Dim newPline As Acad3DPolyline > > Dim pt As Variant > > Dim curbHeight As Double > > Dim curbOffset As Double > > > > On Error Resume Next > > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > > selected here > > If (Err.Number = 0) Then > > If TypeOf ent Is Acad3DPolyline Then > > Set Pline = ent > > curbHeight = ThisDrawing.Utility.GetReal(vbCrLf & "Curb height: ") > > curbOffset = ThisDrawing.Utility.GetReal(vbCrLf & "Offset > distance: > > ") > > Set newPline = MakeCurb(Pline, curbHeight, curbOffset) > > End If > > Else > > 'The user didn't pick something > > End If > > > > End Sub > > > > Public Function MakeCurb(Pline As Acad3DPolyline, height As Double, offset > > As Double) As Acad3DPolyline > > Dim tempPline1 As AcadPolyline > > Dim tempPline2 As AcadPolyline > > Dim newPline As Acad3DPolyline > > Dim temp As Variant > > Dim coords As Variant > > Dim newcoords As Variant > > Dim i As Long > > > > coords = Pline.Coordinates > > If offset <> 0 Then > > Set tempPline1 = ThisDrawing.ModelSpace.AddPolyline(coords) > > temp = tempPline1.offset(offset) > > Set tempPline2 = temp(0) > > newcoords = tempPline2.Coordinates > > tempPline1.Delete > > tempPline2.Delete > > Else > > newcoords = coords > > End If > > For i = 2 To UBound(newcoords) Step 3 > > newcoords(i) = coords(i) + height > > Next i > > Set newPline = ThisDrawing.ModelSpace.Add3DPoly(newcoords) > > newPline.Layer = Pline.Layer > > Set MakeCurb = newPline > > > > End Function > > > > HTH, > > Jeff > > > > > > "Jason Stevens" wrote in message > > news:403e2ea0_2@newsprd01... > > > I am using the following code to try and run a command and have it use a > > > 3dpolyline that gets selected by the user. The problem is at the handent > > > part of the code. How would I have the sendcommand use that 3dpoly? I > > have > > > to use the sendcommand because the 3D Polyline Create Curb command can > not > > > be accessed any other way (as far as I know). > > > > > > Dim ent As Object > > > Dim pt As Variant > > > Dim Cmd1 As String > > > Dim Cmd2 As String > > > Dim Cmd3 As String > > > > > > Cmd1 = "(er_mnl)" > > > Cmd2 = "(zz_sdsk'(er_grdcurb))" > > > Cmd3 = "ldd" > > > > > > On Error Resume Next > > > ThisDrawing.Utility.GetEntity ent, pt, "Pick something:" '3dpoly gets > > > selected here > > > If (Err.Number = 0) Then > > > ThisDrawing.SendCommand Cmd1 & vbCr & Cmd2 & vbCr & Cmd3 & vbCr & > > > "(handent """ & ent.Handle & """)" > > > Else > > > 'The user didn't pick something > > > End If > > > > > > > > > Thanks for any help, > > > Jason > > > > > > > > > > > >
0 Likes