Define a new block with Visual Lisp

Discussion in 'AutoCAD' started by Kaai, Jan 21, 2005.

  1. Kaai

    Kaai Guest

    I think I know the general direction, if anyone has a sample to create a
    simple block with attribute (i.e. circle w/ text in center), I'm sure I
    could take it from there.

    Thanks,
    Kaai
     
    Kaai, Jan 21, 2005
    #1
  2. Kaai

    Jeff Mishler Guest

    Here ya go:

    (setq blk (vlax-invoke (vla-get-blocks *doc*) 'add '(0.0 0.0 0.0)
    "mynewblock"))
    (vlax-invoke blk 'addcircle '(0.0 0.0 0.0) 1.0)
    (setq att (vlax-invoke blk 'addattribute 0.5 0 "MyPrompt" '(0.0 0.0 0.0)
    "MyTag" "-"))
    (vla-put-alignment att acAlignmentMiddleCenter)
    (vlax-put att 'textalignmentpoint '(0.0 0.0 0.0))
     
    Jeff Mishler, Jan 21, 2005
    #2
  3. Kaai

    Kaai Guest

    Thanks Jeff...exactly what I needed...

     
    Kaai, Jan 21, 2005
    #3
  4. Kaai

    Rudy Tovar Guest

    Just another example...

    (defun c:test (/ db)

    (setq db
    (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))

    )

    (setq db (vla-add db (vlax-3d-point(list 0 0 0)) "sample"))

    (vla-addline db (vlax-3d-point (list 0.0 0.0 0.0))(vlax-3d-point (list 0.0
    1.0 0.0)))
    (vla-addline db (vlax-3d-point (list 0.0 0.0 0.0))(vlax-3d-point (list
    0.0 -1.0 0.0)))
    (vla-addline db (vlax-3d-point (list 0.0 0.0 0.0))(vlax-3d-point (list 1.0
    0.0 0.0)))
    (vla-addline db (vlax-3d-point (list 0.0 0.0 0.0))(vlax-3d-point
    (list -1.0 0.0 0.0)))

    (vlax-dump-object ms t)

    (princ)
    )
     
    Rudy Tovar, Jan 21, 2005
    #4
  5. Kaai

    Kaai Guest

    always more than one way to skin a cat....thanks Rudy
     
    Kaai, Jan 21, 2005
    #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.