leventdal Posted February 22, 2008 Share Posted February 22, 2008 Hi, This is my first post in this forum. And as you'll notice I am a beginner to AutoCAD macros. I have worked with Excel macros for quite a while. But with AutoCAD it's all different. I couldn't find a reference help for macros. (object model, methods, collections, etc; such CHM files are present for Excel, Word,...) So I can't even get the coordinates of a dot. I am trying to insert "dot" elements at exactly the same coordinates (x, y, z) with all of the existing "text" elements. Any help on this routine and general help, resources for a beginner would be highly appreciated. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Hickoz_bro Posted February 22, 2008 Share Posted February 22, 2008 i've found that if you install the acad help files when you install the base program, there are LOTS of helpful tips and resource help files... as for your particular problem, i can't help there... i'm a macro newbie too... Quote Link to comment Share on other sites More sharing options...
fuccaro Posted February 24, 2008 Share Posted February 24, 2008 Hello leventdal and welcome in the forum! You are right, the AutoCAD customisation is not like Excel. What you ask is easy to acomplish using a small Lisp routine. First of all, grab together in a selection set all the TEXT entities in the drawing: (setq ss (ssget "X" (list '(0 . "TEXT")))) Now go trough the selection set and for each text entitie extract the insert point coords, wich are stored in the list following the number 10 in the entitie list. Finaly, create an AutoCAD point at those coords. See here my solution: (defun c:test() (setq ss (ssget "X" (list '(0 . "TEXT")))) (repeat (setq i (sslength ss)) (setq tx1 (ssname ss (setq i (1- i))) a10 (assoc 10 (entget tx1)) poi (list '(0 . "POINT") a10) ) (entmake poi) ) ) Don't be afraid if you can't use Lisp routines; click here: http://www.cadtutor.net/forum/showthread.php?t=1390 I renamed this thread. Please in the future use relevant names. Quote Link to comment Share on other sites More sharing options...
leventdal Posted February 28, 2008 Author Share Posted February 28, 2008 Thanks for the quick responses. I couldn't reply to the post earlier due to heavy workload. First of all after Hickoz_bro's advice, I checked the installation disk for CHM files which I couldn't find before. There is one called acadauto.chm Very useful information about using Visual Basic for macros. fuccaro, thanks for the code. But I have no LISP knowledge so for now I'll stick with VB. Here's what I learnt so far: nObjects = Application.ActiveDocument.ModelSpace.Count 'Gets number of objects. Application.ActiveDocument.ModelSpace.Item(i) ' returns the object i in the model space 'You can get many of the object properties through this line Application.ActiveDocument.ModelSpace.Item(i).GetBoundingBox minExt, maxExt 'gets the max min coordinates of an object. Set oAcadPoint = ThisDrawing.ModelSpace.AddPoint(Point) 'creates a point referenced by oAcadPOint Used them with some "for" statements. That's all I needed for now. Thanks again for the help. Quote Link to comment Share on other sites More sharing options...
ERDOS Posted February 17, 2010 Share Posted February 17, 2010 Hello and sorry for bump-ing an old thread - i`m kinda new in lisp programming so here i go askin` for some help: I have some text elements that are 2d (x and y values) and i need to insert "dot" with the values from text - till now fuccaro`s lisp will do fine ...but, i also need to insert in "dot" the z value that is written in text value box ! So ...i need to read the text value box in the z value box and then fucaro`s lisp will take care of rest. Thanks in advance ! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2010 Share Posted February 17, 2010 Try this: (defun c:txt2pt (/ Point i ss ent pt) (defun Point (pt) (entmakex (list (cons 0 "POINT") (cons 10 pt)))) (if (setq i -1 ss (ssget '((0 . "TEXT,MTEXT")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq pt (cdr (assoc 10 (entget ent)))) (Point (list (car pt) (cadr pt) (cond ((distof (cdr (assoc 1 (entget ent))))) (0.0)))))) (princ)) Quote Link to comment Share on other sites More sharing options...
ERDOS Posted February 17, 2010 Share Posted February 17, 2010 That was quick ! and ... IT WORKS !!! Thanks, Lee Mac Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2010 Share Posted February 17, 2010 That was quick ! and ... IT WORKS !!! Thanks, Lee Mac You're welcome Quote Link to comment Share on other sites More sharing options...
ERDOS Posted February 17, 2010 Share Posted February 17, 2010 also, while keeping myself busy with LeeMac lisp (thanks again), i noticed that some of the text is xxxx and i need it to be x.xxx - can i select all my xxxx text and divide by 1000 ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2010 Share Posted February 17, 2010 This should account for non-numerical text being selected too: (defun c:txtby1000 (/ i ss ent num str elst) (if (setq i -1 ss (ssget '((0 . "TEXT,MTEXT")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq num (distof (setq str (cdr (assoc 1 (setq elst (entget ent))))))) (entmod (subst (cons 1 (if num (rtos (/ num 1000.)) str)) (assoc 1 eLst) eLst)))) (princ)) Quote Link to comment Share on other sites More sharing options...
ERDOS Posted February 18, 2010 Share Posted February 18, 2010 some say ... he can code Lisp while sleeping ... we call him Lee Mac Thanks man, it works fine ! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 18, 2010 Share Posted February 18, 2010 some say ... he can code Lisp while sleeping ... we call him Lee Mac Thanks man, it works fine ! Haha Thanks mate Quote Link to comment Share on other sites More sharing options...
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.