ILoveMadoka Posted August 29, 2011 Share Posted August 29, 2011 (edited) I create drawings from Solidworks and bring them into Autocad all day. The centermarks come in as blocks all with unique names. Our drafting standard requires me to delete these center marks.. (I think Lee or someone coded a cool routine that did that for me..) (Lee or someone also wrote a snippet of code that allowed me to select a group of circles and have a centermark placed in each per the current DIMCEN settings.) I was going to attempt some code that automated all that into one routine. I hit a snag when I realized I can't "replace" the block with a standard centermark since placing a centermark requires selecting a circle. I could create a block and replace the block but we have so many varying scales plus our "standard" centermark is not a block so I'd be outside the drafting standard by doing that. I was thinking along the lines of drawing a circle at the block insertion point, then placing a centermark there then deleting the circle. Since there are people here much smarter than me in problem solving I'm asking if this would be the way to go of does someone have a better suggestion? Here is my code where I stopped when I realized I had to pick a circle. It's not much I know... (defun C:SWC (/ I SS) (Prompt "Replace SW Centermark with DIMCEN:") (setq SS (ssget "x" '((0 . "INSERT")(2 . "*SW_CENTERMARKSYMBOL_*")))) (setq I 0) (command ".dim") (repeat (sslength SS) (command "center" (list (ssname SS I) '(0 0))) ;!!!It wants a circle to place the centermark in! Draw & Erase? (setq i (1+ I))) (command "exit") ) (command "Erase" SS "") (princ)) Thanks ... Edited August 29, 2011 by ILoveMadoka rev Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 29, 2011 Share Posted August 29, 2011 I would instead create the individual lines that make up the center mark, here is a very quick example: (defun c:swc ( / a e i l p s ) (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "*SW_CENTERMARKSYMBOL_*")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) p (cdr (assoc 10 (entget e))) l (abs (getvar 'dimcen)) a 0.0 ) (repeat 2 (entmakex (list (cons 0 "LINE") (cons 10 (polar p a l)) (cons 11 (polar p (+ a pi) l)))) (setq a (/ pi 2.)) ) (entdel e) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
ILoveMadoka Posted September 8, 2011 Author Share Posted September 8, 2011 Totally forgot to thank you for this!! Thank you SO much!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2011 Share Posted September 8, 2011 No worries, I hope you could learn from my example Quote Link to comment Share on other sites More sharing options...
ILoveMadoka Posted April 7, 2023 Author Share Posted April 7, 2023 I have a question regarding this code... (defun c:swc ( / a e i l p s ) (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "*SW_CENTERMARKSYMBOL_*")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) p (cdr (assoc 10 (entget e))) l (abs (getvar 'dimcen)) a 0.0 ) (repeat 2 (entmakex (list (cons 0 "LINE") (cons 10 (polar p a l)) (cons 11 (polar p (+ a pi) l)))) (setq a (/ pi 2.)) ) (entdel e) ) ) (princ) ) How do I put this into another lisp file in such a way that it simply runs as part of a process? I am working on a routine that does all sorts of stuff, creates layers, text styles and them moves them to the correct layers and changes existing text to the new created style. How can I put that code into the routine so that it runs as part of the process? (defun c:mysteps () (do stuff....) (do more stuff if conditions are met..) (the code shown above here...) (do stuff....) (do more stuff if conditions are met..) (princ)) would it be as simple as just putting this "in line?" (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "*SW_CENTERMARKSYMBOL_*")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) p (cdr (assoc 10 (entget e))) l (abs (getvar 'dimcen)) a 0.0 ) (repeat 2 (entmakex (list (cons 0 "LINE") (cons 10 (polar p a l)) (cons 11 (polar p (+ a pi) l)))) (setq a (/ pi 2.)) ) (entdel e) ) ) I could try but wanted to ask since I'm here... Quote Link to comment Share on other sites More sharing options...
ILoveMadoka Posted April 7, 2023 Author Share Posted April 7, 2023 Shame on me... that last thing did work... Lee thank you again for the code. I use it all the time! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 8, 2023 Share Posted April 8, 2023 (edited) When adding multiple functions in one lisp I often make them a separate defun this way you test that defun get it working correct then move onto next step. This cut out bit of code has 28 defuns. The code has a defun for each custom dcl there are 5 of them. (doverts) (dotopbot) (dohoriz) (dohordims) (doverdims) Edited April 8, 2023 by BIGAL 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.