CAD/CAM discussion forum > CAD > ThisDrawing.SendCommand don't work

ThisDrawing.SendCommand don't work

Rank: 1

rapidozoo3174

Newbie

posts: 5

Registered: 2012-11-3

Message 1 of 9

 ThisDrawing.SendCommand don't work
08-11-2012 11:12 . am | View his/her posts only
Hi

I Have some application in VBA for Autocad that I transfert to ZWCAD+. Alll work well execept 1 thing.
When I use ThisDrawing.SendCommand it don't work.

I have to select all entities, and cut and paste it on a second drawing.


I use just 1 command line to test and i notice that Zwcad execute the command but just when I quit the VBA.


Some one can help me on this ???


This is 2 of the sendcommand i use:



ThisDrawing.SendCommand "_ai_selall" & vbCr
ThisDrawing.SendCommand "_copyclip" & vbCr


thank's in advance

Rank: 5Rank: 5

Amanda

posts: 19

Registered: 2012-11-6

Message 2 of 9

08-11-2012 04:09 . pm | View his/her posts only
Hello rapidozoo,

i've tried by my side, the sendcommand is ok, use the some code as you did.

Please try the latest version, maybe it was problem but we fixed.

vernum=2012.08.30(5622), packed on 2012.8.30
http://download1.zwsoft.com/en/Z ... 12_enu_20120830.exe
http://download2.zwsoft.com/en/Z ... 12_enu_20120830.exe
http://download1.zwsoft.com/en/Z ... enu_CD_20120830.rar

Rank: 1

rapidozoo3174

Newbie

posts: 5

Registered: 2012-11-3

Message 3 of 9

08-11-2012 10:35 . pm | View his/her posts only
Hi Amanda

I have the latest version 2012.08.30(5622). I really like to find the way to do that.

We plan to buy some ZWCAD license. I starting converting all my Autocad add-on to ZWCAD to test before buying.


This the section of my VBA program:


Private Sub CommandButton17_Click()
.
.
.
ThisDrawing.Application.Documents.Open Source

Set CurrDoc = ThisDrawing.Application.ActiveDocument

FULL_NOM = CurrDoc.FullName
NOM = CurrDoc.Name

ThisDrawing.SendCommand "_ai_selall" & vbCr
ThisDrawing.SendCommand "_copyclip" & vbCr

Dim DOC1 As ZcadDocument
Set DOC1 = Documents.Add

ThisDrawing.SendCommand "_pasteclip " & vbCr & "0,0" & vbCr

.
.
.
.
.
End Sub

Rank: 1

seav735587

Newbie

posts: 9

Registered: 2012-9-7

Message 4 of 9

09-11-2012 04:34 . pm | View his/her posts only
Post Last Edit by seav735587 at 2012-11-11 01:37

UserForm1 module:
Private Sub CommandButton1_Click()
Hide
ThisDrawing.SendCommand "_ai_selall" & vbCr
ThisDrawing.SendCommand "_copyclip" & vbCr
Dim DOC1 As ZcadDocument
Set DOC1 = Documents.Add
ThisDrawing.SendCommand "_pasteclip " & vbCr & "0,0" & vbCr
End Sub

ThisDrawing module:
Private Sub ZcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "PASTECLIP" Then
UserForm1.Show
End If
End Sub

Rank: 1

rapidozoo3174

Newbie

posts: 5

Registered: 2012-11-3

Message 5 of 9

10-11-2012 02:48 . am | View his/her posts only
Thank's for your help, but it still not working.

The ONLY way it make the command (_ai_selall and copyclip) is when I quit the VBA or close the DOC1.

I really like to solve the problem. I have to find the solution before buying ZWCAD.


The is a VBA tutorial or other forum / blog that can help me.

Rank: 1

rapidozoo3174

Newbie

posts: 5

Registered: 2012-11-3

Message 6 of 9

10-11-2012 02:24 . pm | View his/her posts only
hi amanda

Did you use the VBA editor ( provide in ZWCAD) to test my code???

Because, i read in a forum that the vba of ZWCAD don't execute the zwcad command during the vba execution.


than'ks for your help

Rank: 1

seav735587

Newbie

posts: 9

Registered: 2012-9-7

Message 7 of 9

11-11-2012 12:43 . am | View his/her posts only
IMHO, the only way to run commands from a user form is to hidethe form before SendCommand and restore it after command completion.
My previous code works only once (because a new document was
created, I think).
Another working decision is to unload the form and load it again with
vbarun command. I attached sample code. Project1.rar (9.77 KB)

Rank: 5Rank: 5

Amanda

posts: 19

Registered: 2012-11-6

Message 8 of 9

12-11-2012 03:59 . pm | View his/her posts only
Hello Seav,

Sorry to late reply, i tried your code in AutoCAD2012, but it doesn't work either, which version of AutoCAD are you using?

Amanda

Rank: 1

seav735587

Newbie

posts: 9

Registered: 2012-9-7

Message 9 of 9

12-11-2012 08:41 . pm | View his/her posts only
The code was not polished. It shows a technique how to call asynchronous "SendCommand" from a userform context. I'm using it often to run lisp routines from VBA. I attached also autocad project. Tested on acad2000,2004,2007,2010. Zwcad+ will work also.
AcadProject.rar (9.24 KB)
See also