Need to improve a routine

Discussion in 'AutoCAD' started by Chip Harper, Jul 2, 2004.

  1. Chip Harper

    Chip Harper Guest

    I xref the architects floor plan into our template drawing and inserted on
    our layer X-BASE. I use this routine below to toggle the X-BASE layer on and
    off. Works great most of the time, if I toggle the layer off and change the
    ucs then toggle back on (for example) the layer is turned back on but the
    xref is not displayed. Regen All dosen't work, I have to manually reload the
    xref. How do I reload an x-ref from lisp or is there a better way to go at
    this?

    (setq LAYN "X-BASE") ; Set layer name
    (if (tblsearch "layer" LAYN) ; Search for layer
    (progn ; If found toggle
    state
    (setq LAYDATA (entget (tblobjname "layer" LAYN)))
    (setq FRZDAT (boole 6 (cdr (assoc 70 LAYDATA)) 1))
    (setq LAYDATA (subst (cons 70 FRZDAT)(assoc 70 LAYDATA) LAYDATA))
    (entmod LAYDATA)
    )
    (Alert "Change XREF layername to 'X-BASE'") ; If not found alert
    )
     
    Chip Harper, Jul 2, 2004
    #1
  2. Chip Harper

    Rudy Tovar Guest

    (defun c:titleblock (/ blk name)
    (setq blk (ssget "x" '((0 . "insert")(2 . "*XBD*"))))
    (if blk
    (setq name (ssname blk 0)
    name (entget name)
    name (cdr (assoc 2 name))
    name (tblsearch "block" name)
    name (cdr (assoc 70 name))
    )
    )

    (if (= name 36)
    (command "xref" "u" "*xbd*")
    )
    (if (= name 4)
    (command "xref" "r" "*xbd*")
    )
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jul 2, 2004
    #2
  3. Chip Harper

    Chip Harper Guest

    Thanks Rudy. :)
     
    Chip Harper, Jul 2, 2004
    #3
  4. Here is a different take.

    ; determine if the specified item is a
    ; member of the specified collection
    ; returns a vla-object or nil
    (defun item-p (collection item)
    (if
    (vl-catch-all-error-p
    (vl-catch-all-apply
    (function
    (lambda ()
    (setq
    object
    (vla-item collection item)
    )
    )
    )
    )
    )
    nil
    object
    )
    )


    (setq acadObject (vlax-get-acad-object))
    (setq thisDrawing (vla-get-activedocument acadObject))

    ; if layer exists, toggle frozen/thawed state
    (if (setq object (item-p (vla-get-layers thisDrawing) "MyLayerName"))
    (if (= :vlax-true (vla-get-freeze object))
    (vla-put-freeze object :vlax-false)
    (vla-put-freeze object :vlax-true)
    )
    (alert "layer does not exist")
    )


    ; to reload an xref:

    ; assuming that the block name
    ; you are using is an xref.
    (if (setq object (item-p (vla-get-blocks thisDrawing) "MyBlock"))
    (vla-reload object)
    (alert "Block does not exist")
    )

    --
    Autodesk Discussion Group Facilitator


    <snip>
     
    Jason Piercey, Jul 2, 2004
    #4
  5. Shouldn't that using logand in lieu of =

    ?
     
    Jason Piercey, Jul 2, 2004
    #5
  6. Yes, but what would you expect from someone that runs
    around here calling other people's professionalism into
    question, while at the same time, posting code that does
    not even qualify as 'entry level'?



    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning
     
    Tony Tanzillo, Jul 3, 2004
    #6
  7. Chip Harper

    Rudy Tovar Guest

    So what do you call an professional, that runs around here degrading
    people...as they learn to program.
     
    Rudy Tovar, Jul 6, 2004
    #7
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.