Vlisp layer control

Discussion in 'AutoCAD' started by coil, Aug 20, 2004.

  1. coil

    coil Guest

    What is the syntax to draw a line on a layer that is not current while using Vlisp with Active X commands?

    I've searched the Online help within Acad, its says to use "object.layer" but i'm to new at this and that doesnt help me out very much.

    I've also checked the knoweldge base and did a search through the forums here and i only get results talking about how to freeze, turn off layers in the layer manager...

    any help would be apperacited, thanks in advance :)
     
    coil, Aug 20, 2004
    #1
  2. coil

    Paul Turvill Guest

    There are several ways:

    (1) Draw the line, then change its properties to place it on the desired
    layer.
    (2) Temporarily change the layer to the one you want, draw the line, then
    restore the previous layer.
    (3) Construct the line (as with the entmake function) including DXF Group 8
    to place the line in the proper layer.
    ___

    using Vlisp with Active X commands?
     
    Paul Turvill, Aug 20, 2004
    #2
  3. coil

    Jürg Menzi Guest

    Hi coil

    This sample shows you how to do:
    Code:
    (defun MeAddLine2Layer (Pt1 Pt2 Lay / AcaDoc CurSpc FstPnt LayObj LinObj
    NxtPnt)
    (setq AcaDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    LayObj (vla-Item (vla-get-Layers AcaDoc) Lay)
    CurSpc (MeGetCurSpace AcaDoc)
    FstPnt (vlax-3d-point Pt1)
    NxtPnt (vlax-3d-point Pt2)
    )
    (if (= (vla-get-Lock LayObj) :vlax-true)
    (progn
    (vla-put-Lock LayObj :vlax-false)
    (setq LinObj (vla-AddLine CurSpc FstPnt NxtPnt))
    (vla-put-Layer LinObj Lay)
    (vla-put-Lock LayObj :vlax-true)
    )
    (progn
    (setq LinObj (vla-AddLine CurSpc FstPnt NxtPnt))
    (vla-put-Layer LinObj Lay)
    )
    )
    LinObj
    )
    ;
    ; -- Function MeGetCurSpace
    ; Returns the current space object.
    ; Arguments [Type]:
    ;   Acd = Active document object [VLA-OBJECT]
    ; Return [Type]:
    ;   > Mspace or Pspace object [VLA-OBJECT]
    ; Notes:
    ;   None
    ;
    (defun MeGetCurSpace (Acd)
    (if (or (= (getvar "TILEMODE") 1) (> (getvar "CVPORT") 1))
    (vla-get-ModelSpace Acd)
    (vla-get-PaperSpace Acd)
    )
    )
    
    Use:
    _$ (MeAddLine2Layer '(0 0 0) '(10 10 0) "MyLayer")
    #<VLA-OBJECT IAcadLine 00fac404>
    Notes:
    Adds the line to Layer 'MyLayer' even when the Layer is not current, locked,
    frozen or off. Uses the current space to draw the line. Layer name 'MyLayer'
    must exist.

    Cheers
     
    Jürg Menzi, Aug 20, 2004
    #3
  4. coil

    coil Guest

    thanks man, this is excatly what i was looking for!
     
    coil, Aug 20, 2004
    #4
  5. coil

    Jürg Menzi Guest

    Welcome...¦-)

    Cheers
     
    Jürg Menzi, Aug 20, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.