Routine to update ATT w/ pline area & perimeter

Discussion in 'AutoCAD' started by Dave Drahn, Sep 30, 2004.

  1. Dave Drahn

    Dave Drahn Guest

    I have a block with two default attribute values. The block appears
    everywhere in a plan with different attribute values.

    One of the values comes from measuring the area of one of the many polygons
    (made of pline) in the drawing, the other value is

    measurement of length of a polyline (many of them with different length).

    It will be ideal that I can have a clickable script command that allows
    just pick a polygon and a pline, so that

    the attribute values in a block will be updated automatically. Anyone know
    of anything like this?

    Thanks in advance
     
    Dave Drahn, Sep 30, 2004
    #1
  2. Dave Drahn

    T.Willey Guest

    It seems pretty easy to do, but it would be two clicks the way I would do it. First I would select the pline, then I would pick the block and the attributes would up date with the info from the pline. You would need to know what the order of the attributes are, it would make it that much easier.

    Tim
     
    T.Willey, Sep 30, 2004
    #2
  3. Dave Drahn

    SpeedCAD Guest

    hI Dave Drahn...

    First you must do a link between the lwpolyline and block, this you can do it with vlax-ldata-put. Next get the attributes of the block and put area and perimeter value in they.

    Next with a new command you select the lwpolyline, get ldata, this is the block linked, get the area and perimeter value of the lwpolyline and you put that value in the attributes...

    Is not hard...

    Un saludo de SpeedCAD... :D
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Sep 30, 2004
    #3
  4. Dave Drahn

    T.Willey Guest

    Could you write a simple mock program to show this. I think that I could use this later, but I have no experience with ldata.

    Tim
     
    T.Willey, Sep 30, 2004
    #4
  5. Dave Drahn

    SpeedCAD Guest

    Hi...

    Here a sample ;):

    ;;SpeedCAD (C) 2004
    ;;MAKE AREA WITH ATTRIBUTE
    (defun addAtrArea (/ lwpol vla-lwpol pnt vla-atr)
    (setq lwpol (car (entsel "\nSelect PolyLine: "))
    vla-lwpol (vlax-ename->vla-object lwpol)
    pnt (getpoint "\nPick a point for insert attribute: ")
    )
    (setq vla-atr (vla-addattribute
    (vla-get-modelspace
    (vla-get-activedocument (vlax-get-acad-object))
    )
    2.5
    acAttributeModeVerify
    ""
    (vlax-3d-point pnt)
    "AREA"
    (vla-get-area vla-lwpol)
    )
    )
    (vl-cmdf "_.-block"
    "TEST"
    pnt
    (vlax-vla-object->ename vla-atr)
    ""
    )
    (vl-cmdf "_.-insert" "TEST" pnt "" "" "")
    (setq vla-blk (vlax-ename->vla-object (entlast)))
    (vlax-ldata-put
    vla-lwpol
    "BLKAREA"
    vla-blk
    )
    )


    ;;UPDATE ATTRIBUTE
    (defun updateArea (/ vla-lwpol)
    (setq vla-lwpol (vlax-ename->vla-object
    (car (entsel "\nSelect PolyLine: "))
    )
    )
    (if (vlax-ldata-get vla-lwpol "BLKAREA")
    (vla-put-textstring
    (car
    (vlax-safearray->list
    (vlax-variant-value
    (vla-getattributes (vlax-ldata-get vla-lwpol "BLKAREA"))
    )
    )
    )
    (vla-get-area vla-lwpol)
    )
    )
    )

    Un saludo de SpeedCAD... :D
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Sep 30, 2004
    #5
  6. Dave Drahn

    Dave Drahn Guest

    I looked at that, Terry, after you suggested and don't know how to get the
    perimeter in there (AREA works great, though). Is there an object property
    specification for perimeter?

    Thanks.
     
    Dave Drahn, Sep 30, 2004
    #6
  7. Dave Drahn

    Dave Drahn Guest

    Hi, Speed.... I tried loading the code as a lisp file and couldn't get it to
    be recognized as a command. Do I have to do anything special to get it to
    go?

    Using 2004 on XP Pro.

    Thanks!
     
    Dave Drahn, Sep 30, 2004
    #7
  8. Dave Drahn

    Dave Drahn Guest

    Terry, I got this to work for perimeter by substituting LENGTH for HLENGTH
    as the object property. Is this going to screw anything up?

    Thanks.
     
    Dave Drahn, Sep 30, 2004
    #8
  9. Dave Drahn

    SpeedCAD Guest

    Hi Dave...

    Oops, I don't have defined none command, sorry. You type this in the line command:

    First:
    (addAtrArea)

    Next you modify the Polyline, stretch. And type this in the line command:
    (updateArea)

    Un saludo de SpeedCAD... :D
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Sep 30, 2004
    #9
  10. Dave Drahn

    Dave Drahn Guest

    awesome. Thanks!
     
    Dave Drahn, Sep 30, 2004
    #10
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.