Tyke Posted January 9, 2010 Posted January 9, 2010 Hi, I have a form with several buttons on it and 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 Quote
Tyke Posted January 14, 2010 Author Posted January 14, 2010 Got it sorted with the help of CmdrDuh in The Swamp. If anyones interested, you need to hide the form before calling the sub with the SendCommand for PEDIT and after the sub has completed show the form again. And then alls dunky dory ;-)) Quote
todouble22 Posted January 14, 2010 Posted January 14, 2010 Got it sorted with the help of CmdrDuh in The Swamp. If anyones interested, you need to hide the form before calling the sub with the SendCommand for PEDIT and after the sub has completed show the form again. And then alls dunky dory ;-)) can you post the link that you went to over at the swamp and also if you have any good references for vb knowledge i'd be interested. i'm taking a class on that and c++ right now and want to incorporate some cad stuff to it Quote
ollie Posted January 14, 2010 Posted January 14, 2010 Hi The Activedocument.utility.sendCommand runs asynchronously from the vba routine,function etc. that calls it Meaning that it won't run the parsed command until the vba sub has finished (in this case when the form is closed) It sounds like one of the problems you are having is not passing the return character after each line For example Pedit may be used in a manner similar to this //I have used !sset as the selection set. Not sure what method you will be using //Return character in unicode is \r (equivalent to enter or return Dim Cmd as String Cmd = "pedit\rm\r!sset\rjoin\r\r\r" pseudo pedit return //start pedit multiple (m) return //multiple selection selection set, method return //set selection join (j) return //join selected object return //default join return // end join return //end pedit As for running the function using this method you will need to exit the sub by closing the form or ending the function. My best bet is for this task would be to extend the 'Cmd' string to recall the open user form function. For example //Run function that opens the user form from command line or wherever vbarun openUserForm //Append above code ... Cmd = Cmd +"vbarun\ropenUserForm\r" Not the best solution but it will work. Hope that helps, Ollie Quote
Tyke Posted January 18, 2010 Author Posted January 18, 2010 Todd - here's the link for the topic at TheSwamp http://www.theswamp.org/index.php?topic=31627.0 A good reference for VB.NET is Jerry Winters book VB.NET Programming for AutoCAD Customization - Level 1.For VBA Joe Sutphin's book is very good, but VBA is on its way out. You got it in a nutshell Ollie. Thanks. Tyke Quote
Tyke Posted January 18, 2010 Author Posted January 18, 2010 Todd - Jerry Winters has just released a new version of his book 'VB.NET for AutoCAD 2010' Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.