Bill Tillman Posted March 7, 2012 Posted March 7, 2012 I need to refine the way my codes work with MLeaders. Entmake works but I end up with 20 million lines of code. Doing mleader command works but it's unpredictable as other users may have their AutoCAD setup different than mine. As per Lee-Mac's advice I'm trying to use the AddMLeader method but I only find examples which are longer than the entmake process or code which is of no use for my needs. And of course when you look for AddMLeader in the AutoCAD or AutoLISP help all you get is VBA code. Lee-Mac offered this up in an old post and at least I can get it to draw an mleader but I need a way of adding mtext to it as well. Also, this always draws the landing back to the left. How can I control that property. My goal is to be able to call this routine with the points passed as variable to it. No user input needed, or in my case, allowed. (defun c:test (); / p1 p2 ) (vl-load-com) (if (and (setq p1 (getpoint "\nPick First Point: ")) (setq p2 (getpoint "\nPick Next Point: " p1)) ) (vlax-invoke (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace) ) 'AddMLeader (append p1 p2) 0 ) ) (princ) ) Quote
Tharwat Posted March 8, 2012 Posted March 8, 2012 (defun c:test (/ p1 p2 obj ) (vl-load-com) (if (and (setq p1 (getpoint "\nPick First Point: ")) (setq p2 (getpoint "\nPick Next Point: " p1)) ) (progn (setq obj (vlax-invoke (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace ) ) 'AddMLeader (append p1 p2) 0 ) ) (vla-put-textstring obj "just an example") ) ) (princ) ) Quote
Bill Tillman Posted March 8, 2012 Author Posted March 8, 2012 (edited) Hey, that's pretty nifty. Now I just have two more questions. How can I control the direction of the landing? But more important, where the heck does one find information on AddMLeader, or AddCircle, etc.... the net searches I've done come up with just so much unrelated information and all the help in AutoCAD for these commands is geared for VBA, not VLISP. Can you recommend a good source for this? I just downloaded and searched the Visual LISP Developers Bible 2003 Edition. The word AddCircle appears only once in an obscure block of code describing reactors and the word AddMLeader does not show up even once.....in all 183 pages of this doc, AddMLeader is totally absent and unaccounted for. Who is hiding all the information on the very useful commands....? Edited March 8, 2012 by Bill Tillman Quote
BlackBox Posted March 8, 2012 Posted March 8, 2012 Bill, you've really got to use vlax-dump-object more often bud. LoL As you're using the ActiveX component of LISP, yes, most of the documentation is in VBA context. I still use ..\Help\acad_dev172.chm as an ActiveX reference for common items - not sure if the ActiveX reference is posted online anywhere - I know it's not included in the standard online help here: http://exchange.autodesk.com/autocad/enu/help Quote
Bill Tillman Posted March 8, 2012 Author Posted March 8, 2012 Thanks RenderMan. That shows some interesting reading...but here is my quandry. The project I'm working on is a process by where a user enters some data into an Excel spreadsheet. This data is dumped to a simple ASCII text file and then my VLISP code reads this file and prepares a new drawing, on-the-fly, based on the information therein. There is no option to do selections, ask the user which leader he/she wants to work with, etc... no user interface whatsoever. What I'm shooting for is a way around this sloppy code: (command "._MLEADER" pt1 pt2 "PUT THIS TEXT IN") This works fine until the user has their mleader command setup to take the leader or the content first and of course it wrecks havoc on the creation of the drawing. I've also tried creating the mleader ahead of time and then doing properties dump and using all that to create the mleader using entmake. This works even better but it creates about 20 lines of code just for one mleader. What I'm after is to create a function which will take two points, the text for the mleader and some more basic information about left or right angle and dogleg, arrowhead size (if possible) and have it create the mleader using the AddMLeader method. And just to show you how difficult this is for novice...the Exchange link you listed above has zip on the AddMLeader method. I put AddMLeader into the search and this is what I got back: Exchange was not able to find the results which include "AddMLeader". I'm beginning to believe there is a conspiracy out there to hide all the AddMLeader information. Quote
BlackBox Posted March 8, 2012 Posted March 8, 2012 No worries. I can certainly appreciate what you're after, you want a viable SubFunction which you can feed the applicable parameters to yield the desired entities. I get it. Were I familiar with using MLeaders, I would attempt to offer some specific help. I share your frustration with the lack (or discontinuation?) of ActiveX documentation as previously included within the LISP Developer Documentation, which is why I posted this: ... As you're using the ActiveX component of LISP, yes, most of the documentation is in VBA context. I still use ..\Help\acad_dev172.chm as an ActiveX reference for common items - not sure if the ActiveX reference is posted online anywhere - I know it's not included in the standard online help here: http://exchange.autodesk.com/autocad/enu/help ... And just to show you how difficult this is for novice...the Exchange link you listed above has zip on the AddMLeader method. I put AddMLeader into the search and this is what I got back: Exchange was not able to find the results which include "AddMLeader". I'm beginning to believe there is a conspiracy out there to hide all the AddMLeader information. Quote
Lee Mac Posted March 8, 2012 Posted March 8, 2012 Bill, To clarify: To my knowledge, there was never a Visual LISP reference for the ActiveX properties and methods, only the ActiveX & VBA Reference section of the Visual LISP IDE Help Documentation (acadauto.chm). As you may also be aware, this help file was removed along with every other .chm based help file when Autodesk foolishly decided to migrate the help online in AutoCAD versions after and including 2011. However, the acadauto.chm can still be found under "C:\Program Files\Common Files\Autodesk Shared" in these later versions. However, the VBA reference is equally applicable to Visual LISP, since for almost every function, the number of arguments, their data-type and their order are identical to those used in Visual LISP - so translation is straightforward. Concerning the direction of the MLeader landing, investigate the SetDogLegDirection property of the VLA MLeader Object. You will need to use a conditional with your supplied points to test in which direction this should be oriented. I hope this helps, Lee Quote
fathihvac Posted May 24, 2012 Posted May 24, 2012 HELLO THARWAT: Could you make it possible to choose any direction, Quote
irneb Posted May 24, 2012 Posted May 24, 2012 There doesn't seem to be any way of doing that with lisp straight-forwardly. I can't find anything in ActiveX (online version of help can be found here: http://entercad.ru/acadauto.en/). But it appears that the DXF data shows the insertion point of the text. Thus you can place the text to the left/right of the leader line. The following are screen captures showing the differences of the DXF codes to 2 leaders (one with text left of line, the other with text right, both have the leader pointing downwards between the same two points, so the only difference is the text). 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.