PDA

View Full Version : Pausing for user during SendCommand



KevinBarnett
2004-07-01, 01:23 PM
Hi Gang

The following code works but issues an error message at the command prompt:

ThisDrawing.SendCommand ("rotate" & vbCr & "l" & vbCr & vbCr & _
CStr(Round(Pnt(0), 3)) & "," & CStr(Round(Pnt(1), 3)) & vbCr & _
"(pause)" & vbCr)

The error message:
; error: bad function: "\\"

Is there another way to pause for user input during VBA's SendCommand? Or is this a "no go/ dont do it" area?

Thanks,

Kevin.

Coolmo
2004-07-01, 03:13 PM
What are you pausing for? Is it something that you could get VBA to get for you on screen (like a pick point) and then pass that to the sendcommand method? I've set SETQs in VBA before by just sending the command "(setq X value)" to the command line using sendcommand and then any lisp routine or AutoCAD command can access that value.

I'll let someone else tell you why it's bad to use sendcommand method though. I really can't explain it the way it was explained to me.

KevinBarnett
2004-07-02, 05:44 AM
The example is using the rotate command. The macro/program needs the user to provide a rotation of the last object, and - usually this rotation would not be an exact angle, but rather a visually acceptable angle, therefore it would be best if the user can see the last object being "dynamically" rotated whilst supplying the rotation. I could be wrong, but VBA code to do the same task is either impossible or very very complex - thats why I opted for the sendcommand with rotate command, (pause) in lisp when prompting for the angle - simple but ugly. So ugly that an error message appears - thats why I would love to see an alternative.

Thanks,

Kevin.

jim.vipond
2004-07-02, 07:53 AM
Is this the only thing you are doing in the sub/function? If so why not leave the pause for user input off which should leave the command ready for user input anyway.
Make sure you still exit the sub/function cleanly.

Jim

richard.binning
2004-07-02, 10:59 AM
How about writing a lisp routine to grab the last entity and move and rotate it for placement. Then your vba routine could simply insert the block at a known location and use send command to call your newly written lisp routine to finalize the placement and rotation. The best of both worlds.

JSelf
2008-08-07, 05:31 PM
If anyone ever needs to do this something like this will work


CommandString = "(Command ""-Insert"" """ & Selection & """ pause ""1"" ""1"" ""0"")"
ThisDrawing.SendCommand (CommandString & VbCr)

B_Roche
2008-08-08, 05:09 PM
Ive ended up making my own rotate command in VBA, that does so by the user sliding a scroll control across the form. That way, you get to select the appropriate angle for initial viewing ...