kratki spoj Posted January 28, 2014 Posted January 28, 2014 Hi, I'm lookin for a lisp routine that will draw a diagram from selected blocks. These blocks should have some attributes defined within. For example, I could have 25 different blocks on a drawing but all of them would be numbered from 1 to 25, and these numbers would be in a text by them (text from attribute or simple MText). I want to draw a diagram of these same blocks but in number order which they appear. Also there should be a line that connects them. I'm not a programer, so any help is appreciated. Thank's. Quote
Tharwat Posted January 28, 2014 Posted January 28, 2014 Welcome to CADTutor first . Second , if you can upload a sample drawing showing these blocks besides the shape of that aimed diagram Quote
kratki spoj Posted January 28, 2014 Author Posted January 28, 2014 Thank's for reply. For quick response I'll put an image of example what I need. So, on the left there's some blocks scattered on the drawing. On the right is a block diagram from these block in number order. If it's not enough I can always put a .dwg if needed. Thank's again. Quote
Tharwat Posted January 28, 2014 Posted January 28, 2014 Okay , that 's clear enough but I need to know the tag and the block name of that attributed block to include them in the routine . So upload a sample drawing with that block if that possible to continue the routine . Is it okay with you to have the line from the center of the attributed block ? because this would be much easier than deciding which side to start the line from . Quote
kratki spoj Posted January 28, 2014 Author Posted January 28, 2014 Okay , that 's clear enough but I need to know the tag and the block name of that attributed block to include them in the routine . So upload a sample drawing with that block if that possible to continue the routine . Is it okay with you to have the line from the center of the attributed block ? because this would be much easier than deciding which side to start the line from . The tag and the block name are changeable. They do not need to be strictly always the same name. This program should work for different blocks. Diagrams are generated for different kind of blocks, but if u can handle this simple example i presume it would be very easy and useful to upgrade the program. Also it's okay to use center position for now. I don't want to bother you with details, so I'm gonna upload this simple drawing, and if you can get it work for now it would be great.example blocks.dwg Quote
kratki spoj Posted January 30, 2014 Author Posted January 30, 2014 According to your post you've got some kind of idea, would you post it here? I'll have something to start with. Quote
BIGAL Posted January 30, 2014 Posted January 30, 2014 Tharwat it is possible to use the attribute creation order rather than using a unique tag I did this with VBA very easy, expect can be done with VL lisp etc as well. Just post question. Quote
Tharwat Posted January 30, 2014 Posted January 30, 2014 The problem is that with the attribute object that is outside the box since that I used the boundingbox function to get the center point of each attributed block , and it goes like this . Quote
Luís Augusto Posted February 3, 2014 Posted February 3, 2014 Very interesting. Congratulations Tharwat. Quote
pBe Posted February 3, 2014 Posted February 3, 2014 Tharwat it is possible to use the attribute creation order rather than using a unique tag I did this with VBA very easy, expect can be done with VL lisp etc as well. Just post question. Are you referring order of creation BIGAL? Quote
kratki spoj Posted February 6, 2014 Author Posted February 6, 2014 Your test program is another type of program that could be very useful. Drawing polylines to selected blocks is prior work. In my problem described above, drawing a block diagram is the second thing I need to do. If it's possible, could you reprogramme your test version to a version that connects blocks but doesn't draw lines in blocks?So they are connected in the end with a simple line or polyline? Thank's. Quote
Lukilie Posted March 5 Posted March 5 by chance, I'm looking for the same thing, did anyone solve this? It seems that the conversation ended abruptely Quote
mohammadreza Posted May 18 Posted May 18 On 1/30/2014 at 4:42 PM, Tharwat said: The problem is that with the attribute object that is outside the box since that I used the boundingbox function to get the center point of each attributed block , and it goes like this . could i have this lisp ? Quote
marko_ribar Posted May 18 Posted May 18 (edited) Here, quickly written, but you can start with it and develop further more... (defun c:blksconnect ( / mid ss i blklst ll ur att n pp ) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (defun mid ( p1 p2 ) (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) p1 p2) ) (if (setq ss (ssget (list (cons 0 "INSERT") (cons 66 1)))) (progn (repeat (setq i (sslength ss)) (setq blklst (cons (ssname ss (setq i (1- i))) blklst)) ) (foreach blk blklst (vla-getboundingbox (vlax-ename->vla-object blk) (quote ll) (quote ur)) (mapcar (function set) (list (quote ll) (quote ur)) (mapcar (function safearray-value) (list ll ur))) (setq ll (trans ll 0 1) ur (trans ur 0 1)) (setq att (entnext blk)) (while (and att (setq n (cdr (assoc 1 (entget att))))) (if (numberp (setq n (atoi n))) (setq blklst (subst (list n (mid ll ur)) blk blklst)) ) (setq att (entnext att)) ) ) (setq blklst (vl-sort blklst (function (lambda ( a b ) (< (car a) (car b)))))) (vl-cmdf "_.pline" "_non" (setq pp (cadar blklst))) (foreach p (cdr (mapcar (function cadr) blklst)) (vl-cmdf "_non" (list (car p) (cadr pp))) (vl-cmdf "_non" (setq pp p)) ) (vl-cmdf "") ) ) (princ) ) Edited May 21 by marko_ribar 2 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.