Jump to content

Replace Block with Centermark Problem Solving Question....


ILoveMadoka

Recommended Posts

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 by ILoveMadoka
rev
Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

  • 2 weeks later...
  • 11 years later...

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...

 

Link to comment
Share on other sites

Shame on me...

that last thing did work...

Lee thank you again for the code.
I use it all the time!

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...