qball Posted August 12, 2011 Posted August 12, 2011 I have structural drawings and all the rebar is donuts. I've decided to make it a block so I can add it to Tool Palettes. Is there a way (Lisp perhaps) to replace all the donuts in an existing drawing with these new blocks? Quote
BlackBox Posted August 12, 2011 Posted August 12, 2011 A 'donut' is really a Polyline, so unless the donuts are all on a layer that can be isolated, a unique non-bylayer color, etc. I would think you're limited to entsel+replace w/ block for functionality. Quote
qball Posted August 12, 2011 Author Posted August 12, 2011 entsel+replace w/ block for functionality. could you elaborate on that? entsel is not a command. I assume that's part of a Lisp. Quote
BlackBox Posted August 12, 2011 Posted August 12, 2011 (edited) Yes, entsel is a LISP function that prompts the user to select an object. For example, give this a try: (defun c:FOO (/ e v pts) (vl-load-com) (while (/= nil (setq e (car (entsel "\select donut: ")))) (setq v (vlax-ename->vla-object e)) (setq pts (vlax-get v 'coordinates)) (command "._-insert" "[color=red]<BlockName>[/color]" (list (/ (+ (car pts) (caddr pts)) 2.0) (/ (+ (cadr pts) (cadddr pts)) 2.0)) 1.0 1.0 0.0) (entdel e)) (princ)) Edited August 12, 2011 by BlackBox Code revised Quote
qball Posted August 12, 2011 Author Posted August 12, 2011 that works to pick each individual donut. The drawing contains hundreds. I tried Qselect and all the Polylines with the same Global Width. When executing your Lisp I tried entering P for select previous but to no avail. It says "Expects a point or Last". Entering "last" brings up and error "; error: ActiveX Server returned the error: unknown name: "COORDINATES"" Quote
BlackBox Posted August 12, 2011 Posted August 12, 2011 Well, I've revised the code to not error like that again. Edit: There is no previous, or last functionality with entsel. You must select an object. However, like I'm telling you, without some sort of unique criteria (layer, color, global width, etc.) that is specific to all of the 'donuts' (plines) in your drawing, there's no way to create a selection set. If that type of information IS available, post it. Quote
qball Posted August 12, 2011 Author Posted August 12, 2011 In short, the donuts have a Global Width of 3/8" and are on Layer S-R1 Quote
BlackBox Posted August 12, 2011 Posted August 12, 2011 In short, the donuts have a Global Width of 3/8" and are on Layer S-R1 Well why didn't you say so earlier...!? Try: (defun c:FOO ( / *error* ss n activeDoc) (vl-load-com) (defun *error* (msg) (if activeDoc (vla-endundomark activeDoc)) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it (princ)) (if (and (setq ss (ssget "_x" '((0 . "*POLYLINE") (8 . "S-R1") (43 . "3/8\"") [color=red];<- I work in Feet, Not sure of syntax here[/color] ) ) ) (tblsearch "block" (setq n "<BlockName>"))) ((lambda (activeDoc / pts space) (vla-startundomark activeDoc) (vlax-for x (setq ss (vla-get-activeselectionset activeDoc)) (setq pts (vlax-get x 'coordinates)) (vla-put-layer (vla-insertblock (cond (space) ((setq space (vla-get-modelspace activeDoc)))) (vlax-3d-point (list (/ (+ (car pts) (caddr pts)) 2.0) (/ (+ (cadr pts) (cadddr pts)) 2.0))) n 1.0 1.0 1.0 0.0) "S-R1")) (vla-endundomark activeDoc)) (setq activeDoc (vla-get-activedocument (vlax-get-acad-object)))) (cond (ss (prompt (strcat "\n** Block reference cannot be found: \"" n "\" "))) ((prompt "\n** Nothing selected ** ")))) (princ)) Quote
qball Posted August 12, 2011 Author Posted August 12, 2011 I am on holidays next week. I will get back to you on my return. Thanks for you time. I don't intentionally withhold information. I don't know all the important variables, because I don't really know lisp that well. Quote
BlackBox Posted August 12, 2011 Posted August 12, 2011 I am on holidays next week. I will get back to you on my return. Thanks for you time. You're welcome, have a great time! I don't intentionally withhold information. I don't know all the important variables, because I don't really know lisp that well. Of course not, I was being silly. Well, now you know (some)... Quote
qball Posted August 22, 2011 Author Posted August 22, 2011 I'm back. And this is the message I get "** Error: bad SSGET list value **" I loaded the "dowel" block into the drawing, changed the in the Lisp, loaded the lisp, typed FOO and that's the error. I Qselected all the existing donuts, typed FOO and same error message. 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.