TheSwamp

CAD Forums => CAD General => CAD Standards => Topic started by: spawnd on August 23, 2006, 04:41:58 PM

Title: Auto Layering
Post by: spawnd on August 23, 2006, 04:41:58 PM
This might be a question that is already out there, but I couldn't find anything on it...

How do you get a things like dimensions to always come in on a certain layer? 

thanks
Title: Re: Auto Layering
Post by: Jim Yadon on August 23, 2006, 05:00:07 PM
There used to be a LISP routine called autolay. I can't find it on the web and my archives are on an MS WXP machine I can't to right now. Does anyone else around have a copy laying around?
Title: Re: Auto Layering
Post by: LE on August 23, 2006, 05:33:27 PM
Almost forgot, welcome to the swamp!
Title: Re: Auto Layering
Post by: spawnd on August 23, 2006, 05:53:18 PM
thanks. 

I am trying not to use lisp...I know there is a way to add in the key shortcuts in the cui setup for each button, but i can't get it working correctly.  I would like it to create the layer if it is not already in the drawing.  I had it almost set up about 3 months ago, but deleted the button and forgot how to get back to where i was.
Title: Re: Auto Layering
Post by: ronjonp on August 23, 2006, 06:08:40 PM
thanks. 

I am trying not to use lisp...I know there is a way to add in the key shortcuts in the cui setup for each button, but i can't get it working correctly.  I would like it to create the layer if it is not already in the drawing.  I had it almost set up about 3 months ago, but deleted the button and forgot how to get back to where i was.


IMO,

You might want to rethink the not use lisp part (unless you are using LT). There are many great examples on the forum for command reactors to place objects on correct layers and they work quite well.

Ron
Title: Re: Auto Layering
Post by: nivuahc on August 23, 2006, 06:16:30 PM
And if you had taken advantage of the magically disappearing code that LE posted, you could use it for so much more than just what you were asking. Pity it's no longer there.
Title: Re: Auto Layering
Post by: Keith™ on August 23, 2006, 08:38:52 PM
I utilize a couple of VBA routines that do these things:

Forces all blocks to be placed on a specific layer, regardless of the current layer.
Force all dimensions to the dimension layer
force all leaders to the notes layer

I don't have to even think about it. In fact after you have told the program which layer you want the blocks located on, the program will never ask again. It is pretty cool.
Title: Re: Auto Layering
Post by: Jim Yadon on August 23, 2006, 11:49:58 PM
It's unfortunate that you wanting to avoid using LISP for the layer control you seem to be asking for. Autolay is a very useful tool. It can be configured to capture any command line entry and, as I recall, it caught menu and button use as well. A program I use at work already has a variation of autolay built into it so I haven't used that routine in years. Like spaend had said in an earlier post, there are plenty of examples of the use of reactors and others tools that would be useful in accomplishing what you're asking.
Title: Re: Auto Layering
Post by: lispman21 on August 24, 2006, 09:36:58 AM
Well if he doesn't want to use autolisp then thats up to him, but on the other hand I like using lisp and wouldn't mind seeing the code for myself.  So whoever has the code coulde u send it to me or post it here.  That is if you don't mind to.
Title: Re: Auto Layering
Post by: spawnd on August 24, 2006, 10:00:10 AM
The reason for not using a lisp is that I have never write one or created one and never really used them...I've been a draftsmen for 10 years and all the company's I've worked for never used them.  If you can give me a crash course in lisp I will give it a try.  In learning ADT 2006 and creating new standards, palettes, and everything else while creating our new product in 3D vs. old flat drawings.
Title: Re: Auto Layering
Post by: deegeecees on August 24, 2006, 10:27:40 AM
Have you considered VBA?
Title: Re: Auto Layering
Post by: Guest on August 24, 2006, 10:47:20 AM
Here's a link to the AutoLAY.lsp by Eric Schneider??

http://tinyurl.com/lf4le (http://tinyurl.com/lf4le)
Title: Re: Auto Layering
Post by: Keith™ on August 24, 2006, 10:49:14 AM
Try this for dimensions and leaders

It places dimensions on the DIM layer and sets the color to Cyan and places leaders on the NOTE layer and sets the color to Cyan

*note*
As a result of the post following this one, the program has been deleted from this post.

I do not take kindly to password cracking, hacking etc. If you would liked to have the code, all you needed to do was simply ask.
Title: Re: Auto Layering
Post by: Guest on August 24, 2006, 11:58:26 AM
I'm not a huge fan of running password protected programs, however in this case, I was able to get the monkey from the cubicle next to me to crack the code.
Title: Re: Auto Layering
Post by: Maverick® on August 24, 2006, 12:21:25 PM
*WHISTLE*  Foul! *WHISTLE*     :-D
Title: Re: Auto Layering
Post by: Guest on August 24, 2006, 12:22:23 PM
Quote
I do not take kindly to password cracking, hacking etc.

Um, when your password is [REDACTED]1....

Believe me, I wasn't trying to "hack" the program.  I simply wanted to see if there was any malicious code behind the scenes.
When the input box came up I thought, "What the hell."  Quite surprised when it actually worked.


As a side note, one thing I would add to the program is a call to reset the layer if ESC is pressed.  I rarely, if ever, follow through with the dimension command, meaning, I don't type EXIT to end the command.  It would be a nice feature!



Edit - by Nivuahc:
1 - Seriously, don't do that again.
Title: Re: Auto Layering
Post by: Maverick® on August 24, 2006, 12:24:03 PM
   Seriously though man.  On a site full of peeps who program..... not cool.  I know, I know.  Actually not cool anyway but... If it was protected for some reason then the person who created it wanted it that way and has the right to do so. 

  Now go sit in the truck and don't touch any of the buttons.  :wink:
Title: Re: Auto Layering
Post by: Keith™ on August 24, 2006, 12:28:30 PM
Matt, you seem to have missed the entire point. As I stated before, if you wanted the source, all you needed to do was simply ask. It is not about what the password is/was or should be, or even that there was or was not a password on it in the first place. It is merely that you would:

a) attempt to circumvent any password protection, regardless of the strength of the password
b) publicly announce that you hacked the password
c) display the password in a forum where hacking etc. is regarded as a serious violation
Title: Re: Auto Layering
Post by: Guest on August 24, 2006, 12:46:23 PM
Okay okay... I admit I messed up.  I promise never to do that again.

Please accept this nugget of code as a token of my good will.
I use it to automatically put xrefs on a locked layer so they can't be accidentally moved, erased, rotated, etc...

I have it in my ACAD.DVB file so it's always there ready to go.

Part of it came from Tony T a while back.

Code: [Select]
Public blnLayerChange As Boolean
Public Tpent As Long


Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    On Error GoTo ReactorError
    blnLayerChange = False

    Select Case UCase$(CommandName)
        Case "XATTACH"
            Tpent = ThisDrawing.ActiveLayout.Block.Count
        Case "XREF"
            Tpent = ThisDrawing.ActiveLayout.Block.Count
    End Select
    Exit Sub

ReactorError:
    Resume Next
End Sub

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
    Dim Taent As Long
    Dim i As Integer
    Dim MyEnt As AcadBlockReference
    On Error GoTo ReactorError
   
    Select Case UCase(CommandName)
        Case "XATTACH"
            If UCase(CommandName) = "XATTACH" Then
                CreateLayer "BVHG-Xref", True, False, True, "7", "Continuous"
                Taent = ThisDrawing.ActiveLayout.Block.Count
                If Taent > Tpent Then
                    For i = Tpent To Taent - 1
                        Set MyEnt = ThisDrawing.ActiveLayout.Block(i)
                        MyEnt.Layer = "bvhg-xref"
                    Next i
                End If
            End If
        Case "XREF"
            If UCase(CommandName) = "XREF" Then
                CreateLayer "BVHG-Xref", True, False, True, "7", "Continuous"
                Taent = ThisDrawing.ActiveLayout.Block.Count
                If Taent > Tpent Then
                    For i = Tpent To Taent - 1
                        Set MyEnt = ThisDrawing.ActiveLayout.Block(i)
                        MyEnt.Layer = "bvhg-xref"
                    Next i
                End If
            End If
    End Select

    Exit Sub
   
ReactorError:
    Resume Next
End Sub

Function CreateLayer(ByVal LayerName As String, ByVal LayerOn As Boolean, _
                     ByVal LayerFreeze As Boolean, ByVal LayerLock As Boolean, _
                     ByVal LayerColor As String, ByVal LayerLType As String)
    Dim NewLayer As AcadLayer
    Dim color As AcadAcCmColor
   
    Set NewLayer = ThisDrawing.Layers.Add(LayerName)
   
    Set color = New AcadAcCmColor
    With color
        .ColorMethod = acColorMethodByACI
        .ColorIndex = LayerColor
    End With
    NewLayer.LayerOn = LayerOn
    NewLayer.Freeze = LayerFreeze
    NewLayer.Lock = LayerLock
    NewLayer.color = LayerColor
    NewLayer.Linetype = LayerLType
End Function

Again, I'm sorry.  Can you forgive me?
(http://img152.imageshack.us/img152/7805/bighugib5.gif)
Title: Re: Auto Layering
Post by: spawnd on August 24, 2006, 02:16:44 PM
Wow...completely different direction then I thought it it go in...

To re-word the question...In the marco area for a linear dimension (^C^C_dimlinear) you can add to macro by typing after the main text.  I would like to add the -la command with all the layer standards I want for that object.
Title: Re: Auto Layering
Post by: spawnd on August 24, 2006, 03:01:32 PM
alright...I fingured it out (yes I misspelled that way)

if you put the text "^C^C_-la m A-Anno-Dims c 2  lw .35  ps medium  ^C^C_dimlinear" into the macro line in the cui file, it will always come in on the spicified layer.

Thanks to everyone who tried to help and Maverick nice icon.
Title: Re: Auto Layering
Post by: Murphy on August 24, 2006, 03:37:58 PM
Psst... [whisper] That's not his icon, that's the feed from his web cam [/whisper]
Title: Re: Auto Layering
Post by: Maverick® on August 24, 2006, 04:38:30 PM
Yup.  If you keep watching it (me) you will see it (me) move. 


(This reminds me of a tshirt I have.. On the front it asks "Wanna know how to keep an idiot busy?  See back"   :-D)
Title: Re: Auto Layering
Post by: Keith™ on August 25, 2006, 10:51:24 AM
Okay okay... I admit I messed up.  I promise never to do that again.

Sorry, I have been under alot of load here at work and had to devote at least a little time to my job. ;)

No harm no foul .. I mostly brought it up as a word of advice about how TheSwamp operates and what is considered acceptable behavior in our midst.
Title: Re: Auto Layering
Post by: deegeecees on August 25, 2006, 11:22:43 AM
Yup.  If you keep watching it (me) you will see it (me) move. 


(This reminds me of a tshirt I have.. On the front it asks "Wanna know how to keep an idiot busy?  See back"   :-D)

Ok, so what'd it say on the back? Hmmm?
Title: Re: Auto Layering
Post by: Maverick® on August 25, 2006, 11:29:32 AM
Ok, so what'd it say on the back? Hmmm?

Do you really want to know or are you making a funny?  *taking out scorecard*   :-D
Title: Re: Auto Layering
Post by: deegeecees on August 25, 2006, 11:35:58 AM
My interest is truly peaked.
Title: Re: Auto Layering
Post by: Maverick® on August 25, 2006, 12:06:40 PM
"Wanna know how to keep an idiot busy?  See front"
Title: Re: Auto Layering
Post by: Greg B on August 25, 2006, 12:20:56 PM
I don't get it.
Title: Re: Auto Layering
Post by: nivuahc on August 25, 2006, 12:39:31 PM
I don't get it.

And with a face like that, you never will ;)
Title: Re: Auto Layering
Post by: Jim Yadon on August 25, 2006, 05:30:19 PM
Now that definitely goes on the list of strangest thread mutations ever.

On a return note, I just want to add that if you can program in VB, LISP is not a big deal. There are a good many instances I've found where LISP actually performs better than VB. before I got involved in my Linux stuff, I was amazed at the power of reactors. It had prompted me to rewrite some of the LISPs I had written years ago.

Again, strictly my opinion.

So Greg, would you go put this bucket in the corner of that round room over there? :)
Title: Re: Auto Layering
Post by: Greg B on August 25, 2006, 05:41:19 PM
So Greg, would you go put this bucket in the corner of that round room over there? :)

Over there ?

*points aimlessly*
Title: Re: Auto Layering
Post by: AVCAD on September 05, 2007, 11:58:36 AM
create your block on layer 0 and then in the button (if you use one) jsut set  the layer before the insert

something like...

-layer;make;newlayer;color;yellow;newlayer;-insert;block;

making a new layer will always make it current and if the layer is already existing it will just make it current

blocks created on layer 0 will always take the layer and colors associated with whatever layer it is inserted on.
Title: Re: Auto Layering
Post by: jbuzbee on October 15, 2007, 10:41:59 AM
For what it's worth: here's what I use.  Now this hooks into ADT using the AECGENERATELAYERKEY function to generate standard AEC Layers.  Just replace (setq lname (AECGENERATELAYERKEY "ANNOBJ")) with (setq lname "MyTextLayer").  Wrote this back in 2000i - been working flawlessly ever since.  If you need help modifying I'll help as time allows . . ..


Code: [Select]
(vl-load-com)
;;; Set a layer current ;
;;; If pclayer is T the previous clayer string ;
;;; is saved in the variable "jb%oldClayer" ;
;;; ;
(defun jb:setclayer  (lname pclayer / layer)
  (if pclayer(setq jb%oldClayer(getvar "clayer")))
  (if (tblsearch "layer" lname)
    (setq layer(vla-item(vla-get-layers (vla-get-activedocument(vlax-get-acad-object)))lname))
    (setq layer(vla-add(vla-get-layers (vla-get-activedocument(vlax-get-acad-object)))lname)))
  (vla-put-LayerOn layer 1)
  (vlax-put-property layer 'lock :vlax-false)
  (vl-catch-all-apply 'vla-put-Freeze (list layer :vlax-false))
  (vla-put-ActiveLayer (vla-get-activedocument(vlax-get-acad-object)) layer))

;;; ReSet jb%oldClayer ;
;;; sets jb%oldClayer to nil ;
(defun jb:resetclayer  ( / layer doc)
  (if (and jb%oldClayer
  (tblsearch "layer" jb%oldClayer))
    (progn (setq layer (vla-item (vla-get-layers (vla-get-activedocument(vlax-get-acad-object))) jb%oldClayer))
           (vla-put-LayerOn layer 1)
           (vlax-put-property layer 'lock :vlax-false)
           (vl-catch-all-apply 'vla-put-Freeze (list layer :vlax-false))
           (vla-put-ActiveLayer (vla-get-activedocument(vlax-get-acad-object)) layer)))
  (setq jb%oldClayer nil)
  )


;;; Command Will Start ;
 (defun jb:AnnoCommandWillStart(calling-reactor commands / lname)
   (cond((member (car commands) (list "MTEXT" "-MTEXT" "DTEXT" "TEXT"
                                      "-TEXT" "LEADER" "QLEADER" "MLEADER"))
(setq lname (AECGENERATELAYERKEY "ANNOBJ")))

        ((member (car commands) (list "DIMLINEAR" "DIMALIGNED" "DIMBASELINE"
                                      "DIMCONTINUE" "DIMDIAMETER" "DIMANGULAR"
                                      "DIMRADIUS" "DIMORDINATE" "QDIM"))
         (setq lname (AECGENERATELAYERKEY "DIMLINE")))
         )
   (if lname(jb:setclayer lname T)))

;;; Command Ended ;
 (defun jb:AnnoCommandEnded(calling-reactor commands / dwgdimscale)
   (cond ((member (car commands) (list "MTEXT" "-MTEXT" "DTEXT"
      "TEXT" "-TEXT" "LEADER" "QLEADER" "MLEADER"
      "DIMLINEAR" "DIMALIGNED" "DIMBASELINE"
      "DIMCONTINUE" "DIMDIAMETER"
      "DIMANGULAR" "DIMRADIUS" "DIMORDINATE" "QDIM"))
         (jb:resetclayer))
)
   )

;;; Command Cancelled ;
 (defun jb:AnnoCommandCancelled(calling-reactor commands / )
   (cond((member (car commands) (list "MTEXT" "-MTEXT" "DTEXT"
      "TEXT" "-TEXT" "LEADER" "QLEADER" "MLEADER"
      "DIMLINEAR" "DIMALIGNED" "DIMBASELINE"
      "DIMCONTINUE" "DIMDIAMETER"
      "DIMANGULAR" "DIMRADIUS" "DIMORDINATE" "QDIM"))
         (jb:resetclayer))
)
   )


;;; Construct the Command Reactor ;
(defun jb::AnnoConstructCommandReactor  (/)
  (if (= (type *jbAnnoCommandReactor*) 'VLR-Command-Reactor)
    (progn (vlr-remove *jbAnnoCommandReactor*) (setq *jbAnnoCommandReactor* nil)))
  (if (/= (type *jbAnnoCommandReactor*) 'VLR-Command-Reactor)
    (setq *jbAnnoCommandReactor*
           (VLR-Command-Reactor
             "jbTools Annotation Command Reactor" ; Data associated with the editor reactor
             ;; call backs
             '
              ((:VLR-commandWillStart . jb:AnnoCommandWillStart)
               (:VLR-commandEnded . jb:AnnoCommandEnded)
               (:VLR-commandCancelled . jb:AnnoCommandCancelled)
       )) ;_ end of vlr-editor-reactor
          ))

  (if (not (vlr-added-p *jbAnnoCommandReactor*))
    (progn
    (vlr-add *jbAnnoCommandReactor*)
    (vlr-set-notification *jbAnnoCommandReactor* 'active-document-only)))
  (princ))


;;; load reactors ;

   
(if jb::AnnoConstructCommandReactor
  (jb::AnnoConstructCommandReactor))