Making block with VLISP

Discussion in 'AutoCAD' started by JRWalker, May 4, 2004.

  1. JRWalker

    JRWalker Guest

    Hi, I am creating a block within my routine rather than inserting from our
    network. This works somewhat. The program I have written is a LISP file with
    many routines within it. One of those routines is the one which creates the
    block. It works great when I create a snub routine to it and call it. When
    it runs within my whole program, it errors on the creation of its first
    entity (a circle).

    ;SNUB
    (MAKE_SOME_BLK)


    ;ROUTINE
    (defun MAKE_SOME_BLK ()
    (vl-load-com)
    (setq BLKN "SomeBlkName")
    (setq BLKCOLL (vla-get-blocks (vla-get-activedocument
    (vlax-get-acad-object))))
    (setq PT0 (vlax-3D-point '(0.0 0.0 0.0)))
    (setq BLKBAL (vla-add BLKCOLL PT0 BLKN))
    (setq CIRCR 7.5)
    (setq CIR (vla-addCircle BLKBAL PT0 CIRCR))
    )

    It breaks on the vla-addCircle call. I checked and the variable names are
    not used elsewhere. Maybe I am too used to VB rather than VLISP. Does anyone
    have a suggestion to what I am doing wrong?

    Thanks
    JRWalker
     
    JRWalker, May 4, 2004
    #1
  2. JR,

    Well, first off... you should localize your variables, to make sure that
    isn't causing the trouble. 2nd, your posted code works, so it is something
    else in the non-posted code.

    e.g.: (defun MakeSomeBlk (/ blkN blkColl pt0 blkBal circR cir) ;| ... |;)


    --
    R. Robert Bell


    Hi, I am creating a block within my routine rather than inserting from our
    network. This works somewhat. The program I have written is a LISP file with
    many routines within it. One of those routines is the one which creates the
    block. It works great when I create a snub routine to it and call it. When
    it runs within my whole program, it errors on the creation of its first
    entity (a circle).

    ;SNUB
    (MAKE_SOME_BLK)


    ;ROUTINE
    (defun MAKE_SOME_BLK ()
    (vl-load-com)
    (setq BLKN "SomeBlkName")
    (setq BLKCOLL (vla-get-blocks (vla-get-activedocument
    (vlax-get-acad-object))))
    (setq PT0 (vlax-3D-point '(0.0 0.0 0.0)))
    (setq BLKBAL (vla-add BLKCOLL PT0 BLKN))
    (setq CIRCR 7.5)
    (setq CIR (vla-addCircle BLKBAL PT0 CIRCR))
    )

    It breaks on the vla-addCircle call. I checked and the variable names are
    not used elsewhere. Maybe I am too used to VB rather than VLISP. Does anyone
    have a suggestion to what I am doing wrong?

    Thanks
    JRWalker
     
    R. Robert Bell, May 4, 2004
    #2
  3. JRWalker

    JRWalker Guest

    Thanks for the reply. You were exactly right. It was an oversight on my
    part. I had the layer locked that I was creating the circle object on. I did
    not think it would matter since I was creating a block instead of a
    block-reference, but it does matter. Thanks, your statements helped me to
    rethink where the problem was.

    JRWalker
     
    JRWalker, May 4, 2004
    #3
  4. Happy to help.

    --
    R. Robert Bell


    Thanks for the reply. You were exactly right. It was an oversight on my
    part. I had the layer locked that I was creating the circle object on. I did
    not think it would matter since I was creating a block instead of a
    block-reference, but it does matter. Thanks, your statements helped me to
    rethink where the problem was.
     
    R. Robert Bell, May 4, 2004
    #4
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.