Layout Switch Lisp - Erroring out

Discussion in 'AutoCAD' started by Jenna, Dec 7, 2004.

  1. Jenna

    Dann Guest

    Or You could "Alert" them in the reactor. :)


     
    Dann, Dec 7, 2004
    #21
  2. Jenna

    OLD-CADaver Guest

    << I wonder if I could get away with just setting the ltscale??
    That's what we do.
     
    OLD-CADaver, Dec 7, 2004
    #22
  3. Jenna

    OLD-CADaver Guest

    <<right now, I just want to know how I can even run commands in this routine...if I can figure that out, I can just copy the material from my other lisp routine to set all these variables as I would like, because I know that routine works. The insert stuff, etc., is just an excerpt from my other routine, not the whole thing. >>

    Well you can't use COMMAND, and (I think it was Doug that pointed out) vla-setvariable is a better option than setvar. Rather than insert a dummy block(MADIM) just to set dimvars, creat a function that sets them using vla-setvariable that can then be run from the reactor.
     
    OLD-CADaver, Dec 7, 2004
    #23
  4. Jenna

    T.Willey Guest

    Try this inside your reactor.

    Tim

    (defun InsertBlock (BlkName / ActDoc SpaceList BlkName BlkObj CurSpace DimList temp1)
    ; use like (InsertBlock "blockname")

    (setq ActDoc (vla-get-ActiveDocument (vlax-get-ACAD-Object)))
    (setq BlkCol (vla-get-Blocks ActDoc))
    (vlax-for item BlkCol
    (if (= (vla-get-IsLayout item) ':vlax-true)
    (setq SpaceList (cons item SpaceList))
    )
    )
    (foreach item SpaceList
    (setq temp1 (vla-get-Layout item))
    (if (= (vla-get-Name temp1) (getvar "ctab"))
    (setq CurSpace item)
    )
    )
    (setq ErrChk (vl-catch-all-apply '(lambda (x) (vla-Item BlkCol x)) (list BlkName)))
    (if (vl-catch-all-error-p ErrChk)
    (setq BlkName (findfile (strcat BlkName ".dwg")))
    )
    (setq BlkObj
    (vla-InsertBlock
    CurSpace
    (vlax-3d-point '(0 0 0))
    BlkName
    1.0
    1.0
    1.0
    0.0
    )
    )
    (setq DimList (vla-get-DimStyles ActDoc))
    (vlax-for item DimList
    (cond
    ((= (vla-get-Name item) "MADIM")
    (vla-put-Name item "001-DIM")
    )
    ((= (vla-get-Name item) "MADIM$0")
    (vla-put-Name item "001-DIM$0")
    )
    )
    )
     
    T.Willey, Dec 7, 2004
    #24
  5. Jenna

    Jenna Guest

    Thanks, Doug...I will explore this. I do like the idea of setting up
    dimstyles based on variables rather than having a separate file to insert
    each time (and to maintain). Perhaps I can work on this and incorporate it
    in with the next release (the easiest time to work on major changes,
    anyway). That will also give me more time to understand what the reactors
    are doing and different ways I might be able to make use of them.
    Thanks very much!
     
    Jenna, Dec 7, 2004
    #25
  6. Jenna

    Jenna Guest

    Thanks for the confirmation, maybe this is something I can use until I can
    better understand how I might properly incorporate the reactors to improve
    our current lisp routines.
     
    Jenna, Dec 7, 2004
    #26
  7. Jenna

    T.Willey Guest

    Added making the dimstyle active.

    Tim

    (defun InsertBlock (BlkName / ActDoc SpaceList BlkName BlkObj CurSpace DimList ErrChk NewDimSty temp1)

    (setq ActDoc (vla-get-ActiveDocument (vlax-get-ACAD-Object)))
    (setq BlkCol (vla-get-Blocks ActDoc))
    (vlax-for item BlkCol
    (if (= (vla-get-IsLayout item) ':vlax-true)
    (setq SpaceList (cons item SpaceList))
    )
    )
    (foreach item SpaceList
    (setq temp1 (vla-get-Layout item))
    (if (= (vla-get-Name temp1) (getvar "ctab"))
    (setq CurSpace item)
    )
    )
    (setq ErrChk (vl-catch-all-apply '(lambda (x) (vla-Item BlkCol x)) (list BlkName)))
    (if (vl-catch-all-error-p ErrChk)
    (setq BlkName (findfile (strcat BlkName ".dwg")))
    )
    (setq BlkObj
    (vla-InsertBlock
    CurSpace
    (vlax-3d-point '(0 0 0))
    BlkName
    1.0
    1.0
    1.0
    0.0
    )
    )
    (setq DimList (vla-get-DimStyles ActDoc))
    (vlax-for item DimList
    (cond
    ((= (vla-get-Name item) "MADIM")
    (vla-put-Name item "001-DIM")
    (setq NewDimSty item)
    )
    ((= (vla-get-Name item) "MADIM$0")
    (vla-put-Name item "001-DIM$0")
    )
    )
    )
    (vla-put-ActiveDimstyle ActDoc NewDimSty)
    )
     
    T.Willey, Dec 7, 2004
    #27
  8. Jenna

    T.Willey Guest

    Jenna,

    Did you see the code I posted for you? If you did, did it work for you?

    Tim
     
    T.Willey, Dec 8, 2004
    #28
  9. Jenna

    Jenna Guest

    Yes, I did thanks...I think that I will do some more research, though,
    before I pursue this further...maybe trying a way of doing this without
    inserting a block and making sure I understand more about the code I'm
    using.
    Thanks very much!
     
    Jenna, Dec 8, 2004
    #29
  10. Jenna

    T.Willey Guest

    Ok. Good luck with your research.

    Tim
     
    T.Willey, Dec 8, 2004
    #30
  11. Jenna

    Jenna Guest

    Just for anyone who was helping me that's interested, I did create a VERY
    simple routine from this that just changes the ltscale back and forth as
    that is really the issue with plotting that I wanted to solve. I think this
    will really help for right now and I don't think it should cause any
    problems. I thank everyone for their responses and suggestions, they have
    certainly given me food for thought as I review our current routines and
    processes in the coming year.

    (vl-load-com)

    (defun DoThisAfterLayoutSwitch (Caller CmdSet)
    (prompt (strcat "\nLayout tab switched to: " (getvar "ctab")))

    (if (= (getvar "ctab") "Model")
    (setvar "ltscale" (/ (getvar "dimscale") 3.0))
    (setvar "ltscale" 0.33333333)
    )
    (princ)
    )


    (setq MAReactor1
    (vlr-miscellaneous-reactor
    nil
    '(:)vlr-layoutSwitched . DoThisAfterLayoutSwitch)
    )
    )
    )
     
    Jenna, Dec 9, 2004
    #31
  12. Jenna

    Doug Broad Guest

    Much better Jenna. Glad to help.
     
    Doug Broad, Dec 9, 2004
    #32
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.