TheSwamp

Code Red => VB(A) => Topic started by: Tyke on January 12, 2010, 09:27:46 AM

Title: Problem updating drawing after using SendCommand
Post by: Tyke on January 12, 2010, 09:27:46 AM
Hi I'm new here and loking for a little help with a problem,

I have a form with several buttons on it. When the first button is clicked a sub routine is called in which I use the SendCommand with pedit to change all objects on a specified layer to polylines and join them into longer polylines. If I close the form from at this point, it all works fine, but if instead of closing the form I then click another button on the form the actions in the newly called sub are exceuted ok, but when I now close the form the polylines have not been created. (The second sub just draws a few objects, 3 lines and a circle)

Also when I do this sequence of events the second button has to be clicked three times before it draws the objects. But if I reverse the order of clicking the buttons, the button for drawing the objects needs just one click to draw the objects and the polylines are created ok.

The user will decide if either of the buttons will be clicked at all and there is no logical connection between the operations. So I can't disable one of the buttons until the other has been clicked.

It appears to me that there is a connection with sending the pedit command and closing the form before the polylines are created, but I don't know what. You can see the polylines being created and smoothed after the form closes. I've tried updating the active document and sending a regen command directly after sending the pedit command, but neither make any difference.

Anybody got any ideas what I'm doing wrong or what I've not done.

Ben
Title: Re: Problem updating drawing after using SendCommand
Post by: David Hall on January 12, 2010, 09:34:33 AM
Avoid SendCommand if possible
Title: Re: Problem updating drawing after using SendCommand
Post by: Tyke on January 12, 2010, 10:45:19 AM
Thanks for that CmdrDuh, I normally do, but is there a better way to collect all lines, arcs and polylines, convert them all to polylines and then join them all into longer polylines? I couldn't think of one.
Title: Re: Problem updating drawing after using SendCommand
Post by: David Hall on January 12, 2010, 02:00:37 PM
pedit may have to be done the way you going about it, unless, and its a huge unless, you grab the ents, store the points, and erase/redraw the geometry on the fly. 

On a side note, one way I tried to beat the sendcommand synchronous problem was to put the send command in its own function, so that your program is "paused" while the other funcion finishes, and when its done, focus returns to your main program.  Not very elegant, but it does work.
Title: Re: Problem updating drawing after using SendCommand
Post by: David Hall on January 12, 2010, 02:03:11 PM
Also, are you hiding the form while the first button work is being done?  There might be some problem with the form having focus when you push the other buttons that is causing issues.  you might be able to fix the problem with a Hide and Show thrown in.
Title: Re: Problem updating drawing after using SendCommand
Post by: Bryco on January 13, 2010, 03:42:16 PM
I have posted a vba function for polylinejoin that works well.
Search here for that.
Title: Re: Problem updating drawing after using SendCommand
Post by: Tyke on January 14, 2010, 05:51:48 AM
Thanks CmdrDuh, I hadn't thought of hiding the form because there was no user input and I couldn't see the point in it. But I shall certainly give it a try and get back to you.

Bryco, I found a PolylineJoin.txt file in the Lilly_Pond, if that's the one you mean. But there was no author's name in the header. If its yours I shall include your name in the header.

Thanks guys.
Title: Re: Problem updating drawing after using SendCommand
Post by: Tyke on January 14, 2010, 07:43:47 AM
Hi CmdrDuh,

That did the trick.  In the code for the button click event I hid the form, called the sub and showed the form again when the sub was done and all worked well. I did try hiding and showing the form within the sub, but that didn't work.

The other code that was also effected works fine now too.

Thanks a lot CmdrDuh, its the little things that are sometimes more problematic than the bigger ones and not as obvious.
Title: Re: Problem updating drawing after using SendCommand
Post by: David Hall on January 14, 2010, 07:57:54 AM
Glad it worked.
Title: Re: Problem updating drawing after using SendCommand
Post by: It's Alive! on January 15, 2010, 08:27:07 AM
Welcome to TheSwamp Ben!
Title: Re: Problem updating drawing after using SendCommand
Post by: Tyke on January 18, 2010, 01:31:34 AM
Thanks Daniel, nice to be here.