Hi all !
Autocad Map 3D 2009 here.
I have writtent a VBA procedure which uses the very unfamous "sendcommand".
I need to retrieve a hatch boundaries. In VBA, AcadHatch.GetLoopAt will return a null array for a non-associative hatch. So I need to retrieve the boundaries and make the hatch associative first. This is also impossible in VBA (AcadHatch.AssociativeHatch can only be set at creation time).
So I thought I'd just issue a sendcommand "_-hatchedit " to recreate the hatch boundaries and associate them to the hatch. (command "_-HATCHEDIT" (handent "<my handle>") "_B" "_P" "_Y") to be more precise.
BUT, to my surprise, the sendcommand runs asynchronously, even though there is no user input in the process.
The autocad help clearly states that "This method is generally synchronous. However, if the command sent with this method requires any user interaction (such as picking a point on the screen) then this method will continue as soon as the user input begins. The command will then continue to be processed asynchronously."
Here is the sample code (just create a non associative hatch in the drawing to test it) :
Sub test() Dim oAcadHacth As AcadHatch Dim oSelSet As AcadSelectionSet Dim gpCode(1) As Integer Dim gpValue(1) As Variant Set oSelSet = ThisDrawing.SelectionSets.Add("TEST") gpCode(0) = 0: gpValue(0) = "HATCH" gpCode(1) = 71: gpValue(1) = "0" oSelSet.Select acSelectionSetAll, , , gpCode, gpValue ThisDrawing.Utility.Prompt vbCrLf For Each oAcadHacth In oSelSet ThisDrawing.Utility.Prompt "Before : " & oAcadHacth.AssociativeHatch ThisDrawing.SendCommand "(command ""_-HATCHEDIT"" (handent """ & oAcadHacth.Handle & """) ""_B"" ""_P"" ""_Y"")& vbcr" Application.Update ThisDrawing.Utility.Prompt "After : " & oAcadHacth.AssociativeHatch Next oAcadHacth oSelSet.Delete Set oSelSet = Nothing End Sub
This command does not require any user input, so why is it running asynchronously ?
Thanks a lot for your help !
Solved! Go to Solution.