SendCommand

SendCommand

Anonymous
Not applicable
1,306 Views
11 Replies
Message 1 of 12

SendCommand

Anonymous
Not applicable
Hi. I have some problem sending commands to MDT5 by SendCommand method. Sometimes the VBA script will continue processing, while AutoCAD is holding the commands until the script is ended. I have tried to put some DoEvents before and after. I have even tried to do an one million loop with DoEvents without any success. How can I control the SendCommand so it will execute before before VBA continues?
Help is most appreciated
0 Likes
1,307 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
One hack is to put the SendCommand in a sub by itself, and call that sub.
Also, make sure you have all current patches installed.

--
http://www.acadx.com


"peap" wrote in message
news:f0578db.-1@WebX.maYIadrTaRb...
| Hi. I have some problem sending commands to MDT5 by SendCommand method.
Sometimes the VBA script will continue processing, while AutoCAD is holding
the commands until the script is ended. I have tried to put some DoEvents
before and after. I have even tried to do an one million loop with DoEvents
without any success. How can I control the SendCommand so it will execute
before before VBA continues?
| Help is most appreciated
|
0 Likes
Message 3 of 12

Anonymous
Not applicable
Thanks to you Robert I started to look into the sub structure. After isolating SendCommand subs that actually worked I found out the problem: I started a sub in a module from AutoCAD. That sub was calling a form. The form was calling an other sub (with the SendCommand) in the module.
The solution was to hide the form before calling the sub with the SendCommand.
I guess that the active form was the bad guy.
0 Likes
Message 4 of 12

Anonymous
Not applicable
Hi

I want to execute an insert block comamnd from my vb form, ..
but I want a user to specify an insertion point, so what I do is

mform.hide
acadDoc.SendComamnd( "(command ""insert"" """ & mblock & """)")
mform.show

... happens nothing, but when I close this form, the insert command is
executed at last.

any help welcome & thx
lukas
0 Likes
Message 5 of 12

Anonymous
Not applicable
Hi Lukas,

Here is an example of how to do what you're wanting to do.
--
Joe Sutphin
Visual Basic How-To For AutoCAD
for more book details click on the link
http://eomnisource.hypermart.net


Option Explicit

Dim App As AcadApplication

Private Sub Command1_Click()
InsertABlock
End Sub

Private Sub Form_Load()
On Error Resume Next
Set App = GetObject(Class:="AutoCAD.Application")
If Err Then
Err.Clear
Set App = CreateObject(Class:="AutoCAD.Application")
If Err Then
MsgBox "Fatal error - AutoCAD is not available", vbCritical, "AutoCAD Not Available"
Exit Sub
End If
End If
End Sub

Private Sub InsertABlock()
Dim Point As Variant
On Error Resume Next

Point = App.ActiveDocument.Utility.GetPoint(Prompt:="Select an insertion point")

If Err Then
MsgBox "Valid point not selected"
Exit Sub
End If

App.ActiveDocument.ModelSpace.InsertBlock Point, "Block1", 1#, 1#, 1#, 0#
End Sub

If "Block1" is not a block that is already in the AutoCAD database, then you will need
to use a fully qualified path [i.e. "C:\Program Files\AutoCAD 2002\Block1.dwg"


"lukas" wrote in message news:3B67C9D87EFCCF983598E3BB18AFE6B2@in.WebX.maYIadrTaRb...
> Hi
>
> I want to execute an insert block comamnd from my vb form, ..
> but I want a user to specify an insertion point, so what I do is
>
> mform.hide
> acadDoc.SendComamnd( "(command ""insert"" """ & mblock & """)")
> mform.show
>
> ... happens nothing, but when I close this form, the insert command is
> executed at last.
>
> any help welcome & thx
> lukas
>
>
0 Likes
Message 6 of 12

Anonymous
Not applicable
"lukas" wrote in message
news:3B67C9D87EFCCF983598E3BB18AFE6B2@in.WebX.maYIadrTaRb...
> Hi
>
> I want to execute an insert block comamnd from my vb form, ..
> but I want a user to specify an insertion point, so what I do is
>
> mform.hide
> acadDoc.SendComamnd( "(command ""insert"" """ & mblock & """)")
> mform.show
>
> ... happens nothing, but when I close this form, the insert command is
> executed at last.
>

If your objective is to allow the end user to graphically
drag the block insertion into place, then the example Joe
posted does not address that problem.

I'm not entirely sure you can do this from a form, using
the standard SendCommand() kludge, but you can use AcadX.arx
to solve this and many similar problems by implementing your
VBA code as an AutoCAD command.

Attached to this, is a demo that shows how you can use
AcadX.arx to achieve your goal.

The demo requires you to install AcadX.arx (which you can
download from www.caddzone.com/acadx/acadx.htm).

Running the InitApplication() macro will define a new
AutoCAD command named "VBINSERT" that displays a dialog
with a combo box containing the names of all defined blocks.
You can pick one from the combo, and click the "Insert"
button. When you do, the form will hide and you can drag
the block insertion into place, and once you do, the form
reappears. Note that while dragging the block, you can use
the Zoom or Pan buttons on the toolbars without problem.
0 Likes
Message 7 of 12

Anonymous
Not applicable
I am trying to run a layerstyle without regenerating my drawing by only
turning on and off layers. My question is, Is there a limitation on how
many items you can have in the SendCommand? For Example I have been trying
to run layersyles in my AutoCAD drawings I am using SendCommand to do this.
I get an error that says too many line continuations.

If there is a better way to do what I am trying to do I am up for that as
well.

Below is an Example of my code (I need to add more code to this but I get
the above error):

ThisDrawing.SendCommand ("-layer" & vbCr & "s" & vbCr & "0" & vbCr & _
"T" & vbCr & "E*|" & vbCr & "OFF" & vbCr & "E*|"
& vbCr & _
"T" & vbCr & "H*|" & vbCr & "OFF" & vbCr & "H*|"
& vbCr & _
"T" & vbCr & "P*|" & vbCr & "OFF" & vbCr & "P*|"
& vbCr & _
"T" & vbCr & "S*|" & vbCr & "OFF" & vbCr & "S*|"
& vbCr & _
"T" & vbCr & "E*" & vbCr & "OFF" & vbCr & "E*" &
vbCr & _
"T" & vbCr & "H*" & vbCr & "OFF" & vbCr & "H*" &
vbCr & _
"T" & vbCr & "P*" & vbCr & "OFF" & vbCr & "P*" &
vbCr & _
"T" & vbCr & "S*" & vbCr & "OFF" & vbCr & "S*" &
vbCr & _
"T" & vbCr & "A*" & vbCr & "ON" & vbCr & "A*" &
vbCr & _
"T" & vbCr & "A*|" & vbCr & "ON" & vbCr & "A*|"
& vbCr & _
"OFF" & vbCr & "A-WALL-COMP" & vbCr & _
"OFF" & vbCr & "A-WALL-OPEN" & vbCr & _
"OFF" & vbCr & "A*|A-WALL-COMP" & vbCr & _
"OFF" & vbCr & "A*|A-WALL-PATT" & vbCr & _
"OFF" & vbCr & "A*|AP_CAB1" & vbCr & _
"OFF" & vbCr & "A*|AP_DEMO" & vbCr & _
"OFF" & vbCr & "A*|AP_FXT1" & vbCr & _
"OFF" & vbCr & "A*|AP_GHDH" & vbCr & _
"OFF" & vbCr & "A*|AP_GHOS" & vbCr & _
"OFF" & vbCr & "A*|AP_MISC" & vbCr & _
"OFF" & vbCr & "A*|AP_PLB1" & vbCr & _
"OFF" & vbCr & "A*|AP3DEMO" & vbCr & _
"OFF" & vbCr & "A*|SF_FWLN" & vbCr & _
vbCr)
0 Likes
Message 8 of 12

Anonymous
Not applicable
Ouch! There is a limit on the size of the command line,
which may be 256 or 512 characters (not exactly sure), and
that' obviously what's happening to you.

You should probably abandon the command line approach
to this, because the Layer State Manager has an ActiveX
interface that can probably do what you need.

This will get you an instance of it:

Dim LSM as AcadLayerStateManager
Set LSM = GetInterfaceObject("AutoCAD.AcadLayerStateManager")
LSM.SetDatabase(ThisDrawing.Database)

Then, you can use the LayerStateManager object to
manipulate layer states.

"Nathan Hunter" wrote in message
news:0E024C12B6D35906DEA84B18E2AF84E9@in.WebX.maYIadrTaRb...
> I am trying to run a layerstyle without regenerating my drawing by only
> turning on and off layers. My question is, Is there a limitation on how
> many items you can have in the SendCommand? For Example I have been
trying
> to run layersyles in my AutoCAD drawings I am using SendCommand to do
this.
> I get an error that says too many line continuations.
>
> If there is a better way to do what I am trying to do I am up for that as
> well.
>
> Below is an Example of my code (I need to add more code to this but I get
> the above error):
>
> ThisDrawing.SendCommand ("-layer" & vbCr & "s" & vbCr & "0" & vbCr & _
> "T" & vbCr & "E*|" & vbCr & "OFF" & vbCr &
"E*|"
> & vbCr & _
> "T" & vbCr & "H*|" & vbCr & "OFF" & vbCr &
"H*|"
> & vbCr & _
> "T" & vbCr & "P*|" & vbCr & "OFF" & vbCr &
"P*|"
> & vbCr & _
> "T" & vbCr & "S*|" & vbCr & "OFF" & vbCr &
"S*|"
> & vbCr & _
> "T" & vbCr & "E*" & vbCr & "OFF" & vbCr & "E*"
&
> vbCr & _
> "T" & vbCr & "H*" & vbCr & "OFF" & vbCr & "H*"
&
> vbCr & _
> "T" & vbCr & "P*" & vbCr & "OFF" & vbCr & "P*"
&
> vbCr & _
> "T" & vbCr & "S*" & vbCr & "OFF" & vbCr & "S*"
&
> vbCr & _
> "T" & vbCr & "A*" & vbCr & "ON" & vbCr & "A*"
&
> vbCr & _
> "T" & vbCr & "A*|" & vbCr & "ON" & vbCr &
"A*|"
> & vbCr & _
> "OFF" & vbCr & "A-WALL-COMP" & vbCr & _
> "OFF" & vbCr & "A-WALL-OPEN" & vbCr & _
> "OFF" & vbCr & "A*|A-WALL-COMP" & vbCr & _
> "OFF" & vbCr & "A*|A-WALL-PATT" & vbCr & _
> "OFF" & vbCr & "A*|AP_CAB1" & vbCr & _
> "OFF" & vbCr & "A*|AP_DEMO" & vbCr & _
> "OFF" & vbCr & "A*|AP_FXT1" & vbCr & _
> "OFF" & vbCr & "A*|AP_GHDH" & vbCr & _
> "OFF" & vbCr & "A*|AP_GHOS" & vbCr & _
> "OFF" & vbCr & "A*|AP_MISC" & vbCr & _
> "OFF" & vbCr & "A*|AP_PLB1" & vbCr & _
> "OFF" & vbCr & "A*|AP3DEMO" & vbCr & _
> "OFF" & vbCr & "A*|SF_FWLN" & vbCr & _
> vbCr)
>
>
0 Likes
Message 9 of 12

Anonymous
Not applicable
I am using the sendcommand and "rectang" to create a rectangular polyline
that has a .01 fillet. The sendcommand is being held until the macro has
ended. Is there a way to have the rectangle drawn immediately and not held
until exit? The reason for this is I am trying to zoom extents so that I
can view the drawing that is behind my form prior to saving, but because the
rectangle has not been drawn it will not zoom out to the rectangular
perimeter.

I am also using sendcommand for purging and exploding with the same results.
Please excuse any syntax errors.

for intcount = 1 to 10
thisdrawing.sendcommand "explode" & vbcr .....
thisdrawing.sendcommand "purge" & vbcr...
next

I would really like all of these command to execute as they come up.

Thanks

Jerry Bartling
0 Likes
Message 10 of 12

Anonymous
Not applicable
Is there anyway to send a string to the command line in VB using the
acad.tlb from AutoCAD R14.01? I cannot find the send command method in that
version. I can find it in R200* products. Any input would be greatly
appreciated.

Thank you,

Tim Jendro
0 Likes
Message 11 of 12

Anonymous
Not applicable
Hello everyone (again)

I apologize for all the questions. I am trying to get my ACAD2000 VBA app
to work with Release 14. I am not simply trying to use the dvb created in
ACAD2000 vba with Release 14. I am simply exporting forms and modules and
copying the code for ThisDrawing object.

I can't seem to be able to access the ThisDrawing.SendComman method in ACAD
R14. It is viewed as an invalid method. I verified the references, and
they do include the AutoCAD Object Library, point the the installation
directory of ACAD R14. The references do not include the AutoCAD 2000
object library.

Everything I read over the past week or so, seems to say that ThisDrawing
object should contain the SendCommand method in Release 14 API. Is it me?
Or is there a fix?

Dmitry
0 Likes
Message 12 of 12

Anonymous
Not applicable
Is there a SendCommand or a similar method in Release 14 vba? What can I
use to send a command to autocad r14 from vba?

thanx,

Dmitry
0 Likes