highguyuk Posted December 13, 2011 Posted December 13, 2011 (edited) Long time lurker and user of the site. Apologies my first post is a question rather than an answer but now I’ve made the leap of faith who knows the possibilities! I have a drawing with approx. 50 points in it. These points have been created from exporting a file from our MapInfo software into CAD format. Each of these points represents a feature (although everything contained within the drawing is just 1 feature) and I need to be able to attached a symbol (and then associated key) to define the feature when I xref in other similar drawings. I hope I described that ok. After some searching, I’m led to believe I need to use an LSP command/file/code etc.? I have no knowledge of anything LSP based, how to use it or where to begin. The instructions I’ve seen in other threads asking similar questions unfortunately go straight over my head. Could I ask is the LSP the only way to achieve my solution, and if so, is there a (very) basic step by step guide to using the LSP or could someone guide me through please? I understand that there is a need for full AutoCAD to perform this task – which I have access to if needbe. Edited December 13, 2011 by highguyuk Quote
Tharwat Posted December 13, 2011 Posted December 13, 2011 I guess there is no access with Lisp into LT cad version . Am I right ? Quote
highguyuk Posted December 13, 2011 Author Posted December 13, 2011 I guess there is no access with Lisp into LT cad version . Am I right ? I mentioned this in the last line of my thread. My version I use regularly is AutoCAD LT 2011, although I have access to full AutoCAD within the company if I need to use it. So it is not a restriction. So fire away! =) Quote
ReMark Posted December 13, 2011 Posted December 13, 2011 You cannot run lisp routines in LT since it has no support for lisp. You can however utilize a diesel macro. Quote
highguyuk Posted December 13, 2011 Author Posted December 13, 2011 Maybe I should change my "using" profile detail... What's a diesel macro then?! Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 What kind of points are in the drawing? Standard AutoCAD nodes or something else? An example drawing would go a long way. Quote
highguyuk Posted December 13, 2011 Author Posted December 13, 2011 Quite happy to upload the file, where is best to place it so all can download if required? Quote
SLW210 Posted December 13, 2011 Posted December 13, 2011 Click on "Go Advanced" on lower right of reply box, then click on "Manage Attachments", browse to the file and select "Upload". Quote
highguyuk Posted December 13, 2011 Author Posted December 13, 2011 CadTutor Point to Block.dwg File attached. Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 I wrote basically what you want a few months ago... (defun c:RPWB (/ *error* _blocks lst block ss space) ;; Replace Points With Block ;; Alan J. Thompson, 08.23.11 ;; Required subroutine: AT:ListSelect (vl-load-com) (defun *error* (msg) (and *AcadDoc* (vla-endundomark *AcadDoc*)) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))) (princ (strcat "\nError: " msg)) ) ) (defun _blocks (doc / l) (vlax-for x (vla-get-blocks doc) (if (not (wcmatch (vla-get-name x) "*|*,`**")) (setq l (cons (vla-get-name x) l)) ) ) (vl-sort l '<) ) (vla-startundomark (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) (cond ((not (setq lst (_blocks *AcadDoc*))) (alert "Zero blocks in active drawing!")) ((and (setq block (car (AT:ListSelect "Select block to insert:" "" 10 10 "false" lst))) (princ "\nSelect POINT objects to replace: ") (ssget "_:L" '((0 . "POINT"))) ) (setq space (vlax-get-property *AcadDoc* (if (eq (getvar 'CVPORT) 1) 'PaperSpace 'ModelSpace ) ) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (if (vla-insertblock space (vla-get-coordinates x) block 1. 1. 1. 0.) (vla-delete x) ) ) (vla-delete ss) ) ) (*error* nil) (princ) ) (defun AT:ListSelect (title label height width multi lst / fn fo d item f) ;; List Select Dialog (Temp DCL list box selection, based on provided list) ;; title - list box title ;; label - label for list box ;; height - height of box ;; width - width of box ;; multi - selection method ["true": multiple, "false": single] ;; lst - list of strings to place in list box ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite) (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w")) (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;") (strcat ": list_box { label = \"" label "\";" "key = \"lst\";") (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";") (strcat "width = " (vl-princ-to-string width) ";") (strcat "multiple_select = " multi "; } spacer; ok_cancel; }") ) (write-line x fo) ) (close fo) (new_dialog "list_select" (setq d (load_dialog fn))) (start_list "lst") (mapcar (function add_list) lst) (end_list) (setq item (set_tile "lst" "0")) (action_tile "lst" "(setq item $value)") (setq f (start_dialog)) (unload_dialog d) (vl-file-delete fn) (if (= f 1) ((lambda (s / i s l) (while (setq i (vl-string-search " " s)) (setq l (cons (nth (atoi (substr s 1 i)) lst) l)) (setq s (substr s (+ 2 i))) ) (reverse (cons (nth (atoi s) lst) l)) ) item ) ) ) Quote
highguyuk Posted December 13, 2011 Author Posted December 13, 2011 That's great, thanks - but to go all "newbie" and "learner" on you - I have no idea what to do with that. Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 That's great, thanks - but to go all "newbie" and "learner" on you - I have no idea what to do with that. Precisely why I keep this in my signature: http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive Quote
Lee Mac Posted December 13, 2011 Posted December 13, 2011 Another old program of mine, if I've understood the task correctly: http://lee-mac.com/ptmanager.html Quote
highguyuk Posted December 13, 2011 Author Posted December 13, 2011 Precisely why I keep this in my signature: http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive That's a really clear guide. I've managed to do exactly what I wanted. Thank you very much for your assistance and to everyone else who has contributed in the thread. Quote
highguyuk Posted December 15, 2011 Author Posted December 15, 2011 Having tried this once with data, I have now tried to repeat on several drawings and I've developed an issue. When I am run the LSP, it moves the points. So it replaces the points with blocks but moves it to a different part of the drawing. I suspect the issue is to do with the block I'm creating, but I'm not sure. It's annoying because I've already done this and had it working so I'm clearly doing something different - but struggling to pick what?! Quote
HFB Posted May 9 Posted May 9 @alanjt Amazing! 13 years later and this works perfectly in LT2024! Thank you :) 1 Quote
BIGAL Posted May 9 Posted May 9 I have code that I wrote back in 1990 and still works fine today. It was all non VL in that era so should work in LT 24. I am sure others have real old code as well. 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.