INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Move all objects to snap conformity

Move all objects to snap conformity

(OP)
I have a large diagram built by a CAD felon.  He didn't use Snap.  I'd like to select everything and have each item moved to the nearest snap point.  Is there such a command?  

_______________________________
Never confuse movement with action -- E. Hemingway

RE: Move all objects to snap conformity

No, not that I've ever heard of.  But you might find a custom routine has been written for this.

But what all items would need to be moved, just line endpoints?  If a block or text, the insert point?  Polyline vertices?

RE: Move all objects to snap conformity

(OP)
Yes, I wasn't clear.  It's all single-line text entries that are the issue.  Sure looks like a simple VBA routine don't it?  

_______________________________
Never confuse movement with action -- E. Hemingway

RE: Move all objects to snap conformity

I don't know VBA - but it looks like a fairly simple lisp to me :)

Select all text entities, extract coordinates of insert point, "round" those x & y values to the x & y snap settings, substitute the rounded values into the entity data of the text, "entmod" to update/edit the text location.

RE: Move all objects to snap conformity

(OP)
That's beautiful.  All I need is the complete snippet!  Oh, and I just discovered that this CAD fraud used only MTEXT.  Which was really not the thing to do here.  Okay, thanks.  Carl.

_______________________________
Never confuse movement with action -- E. Hemingway

RE: Move all objects to snap conformity

I can give you some code when I get a few minutes.....

In the meantime you could explode all mtext to text, and use the Express Tools "tjust" to make sure all have the same justification (if not a problem).

RE: Move all objects to snap conformity

OK here's more than a snippet :)
Try pasting the following lisp code into a file, save and load.  Tested briefly on text entities.  Starts with "txtsnap".
==========================================

(defun c:txtsnap ()
   (command "undo" "be")
   (setq SnapStart (getvar "SNAPBASE"))
   (setq Xstart (car SnapStart)
         YStart (cadr SnapStart)
   )
   (setq xsnap (getreal "\nEnter x snap spacing: "))
   (setq ysnap (getreal "\nEnter y snap spacing: "))
   (setq txtset (ssget '((0 . "*TEXT"))))
   (setq LenSet (sslength txtSet))
   (setq Ecount 0)
   (repeat LenSet
      (setq Ename (ssname txtset Ecount))
      (setq Edata (entget Ename))
      (setq InsPt (cdr (assoc 10 Edata)))
      (setq Xins (car InsPt)
            Yins (cadr InsPt)
      )
      (setq Xround (roundsnap Xins xsnap xstart)
            YRound (roundsnap Yins ysnap ystart)
            PtRound (list Xround YRound)
      )
      (setq NewInsData (cons 10 PtRound))
      (setq newdata (subst NewInsdata (assoc 10 Edata) Edata))
      (entmod Newdata)
      (setq ECount (1+ Ecount))
   )
   (command "undo" "e")
   (princ)
)
;;--------------------------------
(defun roundsnap (val incr base)
  (setq Snapdist (- val base))
  (setq NewNum (/ Snapdist incr))
  (setq NumSteps (atoi (rtos NewNum 2 0)))
  (setq Rounded (* NumSteps incr))
  (setq NewCoord (+ base rounded))
)

RE: Move all objects to snap conformity

(OP)
With help from thread 682356 to run the LISP, Hooray, a few challenges are solved.  Plus I learned how to explode MText, which is logical (so much so you'd think AutoCAD 2002 Help would mention it).  

Many thanks, Carl!  

_______________________________
Never confuse movement with action -- E. Hemingway

RE: Move all objects to snap conformity

You're welcome, glad to see it helped!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close