Joro-- Posted November 13, 2005 Posted November 13, 2005 Hi, not long ago I started learning VBA and I had a bit of success til it came to use The SendCommand method. If I use an exmple given by another member here, say I am trying to add an arc. Using the SendCommand method the code is as follows: ThisDrawing.SendCommand "_arc" & vbCr & "2,3,4" & vbCr & "5,7" & vbCr & "12,10" & vbCr Now I need to copy this arc from Point1 to Point2, How can I do it and how can I refer to the already drown arc? Thanks in addvance Quote
Murph Posted November 13, 2005 Posted November 13, 2005 Instead of SendCommand why not use ThisDrawing.AddArc? That way you could feed it an array of points and have the arcs center at those points? I can post more on this topic Monday as all of my code resides at work. Quote
Joro-- Posted November 13, 2005 Author Posted November 13, 2005 Actually I don't need the SendCommand method for creating arc , I gave this example just for simplicity. I just need the proper way of implementation of sendCommand, and especially I would like to know how to refer in SendCommand to programatically created objects, e.g. if I have programatically created an object (arc) and I have two points taken from the interaction with the user, how can I copy objArc from Pt1 to Pt2 with SendCommand method! If I can figure out this SendCommand may be useful in more complex cases. I will really appreciate if you can help me! Quote
Spageddie Posted November 13, 2005 Posted November 13, 2005 Have a look at this post.. http://www.cadtutor.net/forum/viewtopic.php?t=4971 Quote
Olhado_ Posted December 23, 2008 Posted December 23, 2008 I am in the same boat as "Joro--"; but I guess the linked thread must have been wiped off the forum. Could someone explain the VBA SendCommand again? Thanks. Quote
rocheey Posted December 24, 2008 Posted December 24, 2008 Actually I don't need the SendCommand method for creating arc , I gave this example just for simplicity. I just need the proper way of implementation of sendCommand, and especially I would like to know how to refer in SendCommand to programatically created objects, e.g. if I have programatically created an object (arc) and I have two points taken from the interaction with the user, how can I copy objArc from Pt1 to Pt2 with SendCommand method! If I can figure out this SendCommand may be useful in more complex cases. I will really appreciate if you can help me! Firstly, "proper implementation" and "SendCommand" arent normally used in the same sentence. Its a kludge, a workaround, and like "Goto", should be avoided at any and all costs. Its like running a DOS batch file from VBA - you have no idea if everything went ok, and , if its doing a lot of work, you WONT EVEN HAVE ANY IDEA IF ITS DONE RUNNING YET. Secondly, you dont wanna use it in "more complex" cases, because , since your VBA code wont know if a problem occured, or if its done running (and your code immediately jumps to the next command ) you'll run into all sorts of strange bugs that will be near impossible to trace; they may appear as different problems on different machines. Thirdly, to specifically copy one object to another place, using sendcommand, will actually take MORE work than doing it correctly, using VBA. More work, that is, for whatever guys end up posting the code here. It will end up as some of these threads do, with yet more questions, more bugs, and more rewrites, all in the name of doing something incorrectly. Having said that, to refer to objects using Sendcommand requires a third kludge; you have to imbed a lisp command. Im not dissing lisp here; but i am dissing the use of lisp in send command, from a VBA macro, when other, "correct" methods can be used. what you'll have to do is get the entity handle from either a selection set, or a "GET" type vba command that allows selecting of an entity. Once you have the entity handle, you'll embed your sendcommand with "handent", followed by the handle, as a string, embedded in quotations marks [CHR(34)], all embedded in brackets. You build the whole thing as a custom string, and spam it to the command line in one large glop, rather like the way mashed potatoes are placed onto the tin plates at army mess halls. Quote
CmdrDuh Posted December 24, 2008 Posted December 24, 2008 ditto that ^ Avoid SendCommand at all costs Quote
PeterCharles Posted October 16, 2009 Posted October 16, 2009 I've got a VBA macro that selects all text in model space then uses SendCommand to use txtexp to explode all the text. If it's bad practice to use SendCommand how can I achieve the same result without using it?? Peter Quote
Olhado_ Posted October 16, 2009 Posted October 16, 2009 I've got a VBA macro that selects all text in model space then uses SendCommand to use txtexp to explode all the text. If it's bad practice to use SendCommand how can I achieve the same result without using it?? Peter There is an .Explode command. However, since txtexp is an Express command I am unsure if the standard explode will still work. The command above is the standard explode. Quote
SEANT Posted October 16, 2009 Posted October 16, 2009 I don’t think Text/MText implements the Explode method. Mimicking TXTEXP is an interesting notion, however. Given the availability of ThisDrawing.Export and ThisDrawing.Import, and those methods’ ability to work with WMF, then the ET’s TXTEXP could conceivably be reproduce with VBA. Essentially the txtexp routine scripts this sequence of events: 3dRotates the text 180 degrees about the Y axis. WMFOUT that selection set. WMFIN that same file. at scale factor = 1 (Hopefully). Re - 3dRotates that freshly imported geometry (BlockReference, probably named “WMF0”) 180 degrees about the Y. Explode Reference. If someone were really in need of that feature it would be worth a try. Quote
PeterCharles Posted October 16, 2009 Posted October 16, 2009 There is an .Explode command. However, since txtexp is an Express command I am unsure if the standard explode will still work. The command above is the standard explode. Standard explode doesn't work on text which is why txtexp exists. Quote
PeterCharles Posted October 16, 2009 Posted October 16, 2009 I don’t think Text/MText implements the Explode method. Mimicking TXTEXP is an interesting notion, however. If someone were really in need of that feature it would be worth a try. Firstly, "proper implementation" and "SendCommand" arent normally used in the same sentence. Its a kludge, a workaround, and like "Goto", should be avoided at any and all costs.From a previous post, hence my question, what's the alternative? 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.