vbCr and SendCommand

vbCr and SendCommand

Anonymous
Not applicable
3,099 Views
12 Replies
Message 1 of 13

vbCr and SendCommand

Anonymous
Not applicable
I am somewhat of a beginner to the "sendcommand" so i am going to ask what sounds like a stupid question. What does "vbCr" stand for? I assume it is "enter" or something. If so, is there a list of other ones like this. I am trying to send a simple command to the command line where i am entering coordinates instead of asking for user input and i want to make sure I am putting the string in correctly. Thanks!
0 Likes
3,100 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
Do an Index search on "constants, described" in the VBA Editor Help.
0 Likes
Message 3 of 13

Anonymous
Not applicable
vbCr - equivalent = chr(13), Description = Carraige Return Character.



Not sure what that means exactly.


What is wrong with this code line:


ThisDrawing.SendCommand "rectangle" & vbCr & "49',13',0" & vbCr & "-15',-9',0" & vbCr



For some reason, it gets the first coordinate, and says "2d point required" after trying the second coordinate.

0 Likes
Message 4 of 13

Anonymous
Not applicable
Convert all your coordinates to their equivalents in inches. (For example: 13' would be 156).
0 Likes
Message 5 of 13

Anonymous
Not applicable
My first set of coordinates that is in Feet worked, it just stopped working when it tried inputing the second set.
0 Likes
Message 6 of 13

Anonymous
Not applicable
Try entering AutoCAD commands at the command line to duplicate exactly what you are trying to do with the code. If there is a bad entry, AutoCAD will let you know.
0 Likes
Message 7 of 13

Anonymous
Not applicable
As you suggested, i put it in by hand....here is the command line:



Command: _rectang


Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: 42',13'



Specify other corner point or [Area/Dimensions/Rotation]: @-15',-9'



So, I assume I need to add the @ symbol somewhere in that string?

0 Likes
Message 8 of 13

Anonymous
Not applicable
This Worked!



ThisDrawing.SendCommand "rectangle" & vbCr & "49',13'" & vbCr & "-15',-9'

0 Likes
Message 9 of 13

Anonymous
Not applicable
Hi,

Your code will be far easier to write and maintain if you use code like
this instead of the SendCommand process.


Dim VerticesList(0 To 7) As Double
Dim oPoly As AcadLWPolyline

' Assign vertice values to the array.
VerticesList(0) = 49
VerticesList(1) = 13
VerticesList(2) = 49
VerticesList(3) = -9
VerticesList(4) = -15
VerticesList(5) = -9
VerticesList(6) = -15
VerticesList(7) = 13
' watch word wrap on next line
Set oPoly = ThisDrawing.ModelSpace.AddLightWeightPolyline(VerticesList)
oPoly.Closed = True
oPoly.Layer = "myLayer" ' If you wish to set the polyline layer


Regards


Laurie Comerford

mahenderson wrote:

> This Worked!
>
> ThisDrawing.SendCommand "rectangle" & vbCr & "49',13'" & vbCr & "-15',-9'
>
0 Likes
Message 10 of 13

Anonymous
Not applicable
Thank You Laurie. I will give that a whirl.
0 Likes
Message 11 of 13

Anonymous
Not applicable

The term Carriage Return is an old fogey term that refers to typewriters. (Cue big band music. . .)

In the old days, folks would whack away at an old Underwood typewriter, and the paper would step to the right one space at a time. When they got close to the right margin of the page, a little bell would DING, letting them know that they should wrap it up and RETURN the CARRIAGE, which was what they called the cylinder that the paper wrapped around. Otherwise, they might type right off the right side of the page. They would then push a lever on the right side of the machine and slide the whole thing back to the left. This was a CARRIAGE RETURN.

One other important typewriter-based action was the Line Feed. If you returned the carriage, but didn't give it that little extra nudge at the end, the carriage would not roll up the paper to the next line, and you could end up typing right over your previous line. So the Line Feed is another important term, and it's usually directly connected to the carriage return.

You'll see the VB term vbCR, but you'll also see vbCRLF, which is Carriage Return/Line Feed. You may need to use vbCRLF in some cases where vbCR doesn't quite get the job done.

But I agree with Laurie - Use AutoCAD methods like AddPolyline whenever possible. Sendcommand isn't always consistent.

0 Likes
Message 12 of 13

Anonymous
Not applicable
I agree with the others, coding the polyline in is more flexible and gives you more control than the command line. However it is worth noting that, because autocad excepts the spacebar instead of return (enter) at the command line, you could send one string to the command line by replacing vbCrs with " " -> ThisDrawing.SendCommand "rectangle 49',13' -15',-9'"
0 Likes
Message 13 of 13

Anonymous
Not applicable
I have two questions/comments regarding some of the replies. What if I wanted to code in a FENCE. Could I use the polyline concept for that as well? Also, I have seen the " " before in command line code and I am glad to see that it mean space. Thank you to all of you for your replies.
0 Likes