Jump to content

Dont snap to Locked Stuff! / Lock a block or Object!


TimZilla

Recommended Posts

A quickie...

 

Will allow one to snap to anything except objects on locked layers.

 

(defun test (/ pt ss)
 (while (not pt)
   (if
     (and
       (setq pt (getpoint "\nSpecify point: "))
       (setq ss (ssget pt))
       (not (zerop
              (cdr (assoc 70 (entget (tblobjname "layer" (cdr (assoc 8 (entget (ssname ss 0))))))))
            )
       )
       (princ "\nCannot snap to object on locked layer!")
     )
      (setq pt nil)
      pt
   )
 )
)

Link to comment
Share on other sites

  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

  • TimZilla

    18

  • alanjt

    16

  • ReMark

    6

  • Lee Mac

    5

Top Posters In This Topic

A quickie...

 

Will allow one to snap to anything except objects on locked layers.

 

(defun test (/ pt ss)
 (while (not pt)
   (if
     (and
       (setq pt (getpoint "\nSpecify point: "))
       (setq ss (ssget pt))
       (not (zerop
              (cdr (assoc 70 (entget (tblobjname "layer" (cdr (assoc 8 (entget (ssname ss 0))))))))
            )
       )
       (princ "\nCannot snap to object on locked layer!")
     )
      (setq pt nil)
      pt
   )
 )
)

 

 

 

 

 

This is BIG!, thank you very much.

 

 

I promise to always to always challenge you all.

Link to comment
Share on other sites

is there something I need to do to edit it?

 

what book or site do you recommend to show me how to create lisp?

Link to comment
Share on other sites

You're welcome. Like I said, it was a quickie.

Edit it for what?

 

Afralisp.net is a good starting point.

 

 

I couldn't get it to work.

Link to comment
Share on other sites

It's a subroutine. Call it with (test)

 

 

Yeah, I did.

 

I typed,

 

(test), and in the command line it says:specify point

 

when I clicked on a locked object, although the pick box did appear, it said

Cannot snap to object on locked layer!

 

thats all it does.

 

when I go to draw a line, it still snaps on the locked layer, and lets me draw then line. So I am not sure what the point of it is.

 

Maybe im just doing something wrong.

Link to comment
Share on other sites

Yeah, I did.

 

I typed,

 

(test), and in the command line it says:specify point

 

when I clicked on a locked object, although the pick box did appear, it said

Cannot snap to object on locked layer!

 

thats all it does.

 

when I go to draw a line, it still snaps on the locked layer, and lets me draw then line. So I am not sure what the point of it is.

 

Maybe im just doing something wrong.

Jesus you have a horrible way asking for help.:roll:

It's a way to ignore locked layers when snapping a point. It won't alter your other programs.

 

For what you are wanting, you would need a command that can be called transparently.

(defun c:IL (/ pt ss)
 ;; Ignore locked layers for picked point
 ;; Alan J. Thompson, 04.28.10
 (if (zerop (getvar 'cmdactive))
   (princ "\nIL must be called from within another command.")
   (while (not pt)
     (if
       (and
         (setq pt (getpoint "\nSpecify point (Locked layers will be ignored): "))
         (setq ss (ssget pt))
         (not
           (zerop
             (cdr (assoc 70 (entget (tblobjname "layer" (cdr (assoc 8 (entget (ssname ss 0))))))))
           )
         )
         (princ "\nCannot snap to object on locked layer!")
       )
        (setq pt nil)
        (if pt
          ((lambda (p)
             (vla-sendcommand
               (cond (*AcadDoc*)
                     ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
               )
               (strcat "_non " (car p) "," (cadr p) "," (caddr p) " ")
             )
           )
            (mapcar (function (lambda (x) (rtos x 2 16))) pt)
          )
        )
     )
   )
 )
 (princ)
)

Once you execute the command (line, etc.), type 'IL and pick your point.

 

eg.

Command: l LINE Specify first point: 'il
Specify point: ENDP
of
Cannot snap to object on locked layer!
Specify point:
Specify first point: Specify first point: _non 
2061163.30167356,534789.3919210184,0
Specify next point or [undo]:

Link to comment
Share on other sites

(*edit* this comment was for the post before your previous, just noticed your new post*)

 

would adding this command you made to the move, copy, and the line command make it work?

 

I think it would because:

 

when I am moving, copying or drawing a line, I dont want the onsnaps to stick to stuff that is locked. The main reason is because the mechanical and structure is elevated (3d). I want everything I draw, move or copy to be at 0,0 z coordinate. Because my program will get a lot of errors if everything I draw isnt flat. My program elevates my stuff later, but I have to draw it flat. Then it creates a solid 3d block to work with navisworks. I usually copy and track from my walls or ceiling grid. Thats it.those are at 0,0 so they are OK.

 

I want to lock everything else and keep it there for reference, without it interfering with what I am trying to do.

 

 

If I could make new commands.

 

Move - that allows me to move stuff without snapping or having that pick box appear on locked object.

 

Copy - that allows me to copy stuff without snapping or having that pick box appear on locked object.

 

Line - that allows me to draw a line without snapping or having that pick box appear on locked object.

 

The reason why I dont like that pick box to appear is:

 

sometimes I want to track from the center of a particular wall. Well, there might be a hvac duct right above that wall and the snap always wants to snap onto the duck(locked object) and it makes it hard from me to track off of the wall. I just want it to ignore it completely.

Link to comment
Share on other sites

Well, you don't have to help me man, I am just trying to learn.

 

Believe it or not, I take most of these LISPs you guys make and look at them and try to understand them. I printed out every tutorial on the site you referred me to. Once I learn LISP, I will repay the favor to people needing help. Don't you worry.

 

Wish there was something like a Ghost xref.

 

Just for reference, cant snap to it, track from it. I will invent this some day!

Link to comment
Share on other sites

I made a small modification, so make sure you take it now.

 

What pick box are you talking about?

 

 

i meant the snap marker. sorry

Link to comment
Share on other sites

Well, you don't have to help me man, I am just trying to learn.

What the hell kind of comment is that? I was a little peeved with your attitude and you repay me this this. None of us on here get paid to help and I don't remember receiving any from you. And no, I do not want money from you, I just want you to keep that in mind.

 

Believe it or not, I take most of these LISPs you guys make and look at them and try to understand them. I printed out every tutorial on the site you referred me to. Once I learn LISP, I will repay the favor to people needing help. Don't you worry.

The only form of payment I want is a good attitude and a thank you.

 

Wish there was something like a Ghost xref.

No clue what you are talking about here.

 

 

Just for reference, cant snap to it, track from it.

Can't snap to what? It will allow you to only snap to objects on unlocked layers. Which is exactly what you asked for.

Link to comment
Share on other sites

OK, could you point out what I said wrong?

 

My Comments:

 

1) This is BIG!, thank you very much.

I promise to always to always challenge you all.

 

2) is there something I need to do to edit it? what book or site do you recommend to show me how to create lisp?

 

3) couldn't get it to work.

 

4) Yeah, I did. I typed,(test), and in the command line it says:specify point.when I clicked on a locked object, although the pick box did appear, it said Cannot snap to object on locked layer! thats all it does. when I go to draw a line, it still snaps on the locked layer, and lets me draw then line. So I am not sure what the point of it is. Maybe im just doing something wrong.

 

 

You:

Jesus you have a horrible way asking for help.

It's a way to ignore locked layers when snapping a point. It won't alter your other programs.

 

 

 

Me:

Well, you don't have to help me man, I am just trying to learn.

 

 

 

 

 

 

now that you have RE-read all of this you will realize that I was VERY happy you were helping me and that YOU are the one who over reacted for a reason I am unsure of.

 

AGAIN! I will say thank you, because I really did, and still do appreciate that you took time out of your life to help me.

 

BUT, you are not going to sit here and convince me and others that I was being rude to you. I think you are thinking up stuff in your own head, maybe reading my comments with an angry voice in your head or a devil on your shoulder. I don't know how my comments offended you in any way, and if they did, you need more help dealing with people than I need with AutoLISP buddy.

 

Peace! and please just close this thread. This is not good for the site and I am sorry I had to be a part of this. I am not a mean person and I said nothing wrong. Wow, what a mess.

Link to comment
Share on other sites

What the hell kind of comment is that? I was a little peeved with your attitude and you repay me this this. None of us on here get paid to help and I don't remember receiving any from you. And no, I do not want money from you, I just want you to keep that in mind.

 

 

Sorry to keep at this, but I am seriously being punked right? where is Ashton Kutcher at?

 

I had no attitude, I never said you get paid to do this, and I never offered you any money. where did this come from?

 

These are all thoughts that come from your sick head. I would be willing to bet that you are Bi-Polar.

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