Convert to ActiveX

Discussion in 'AutoCAD' started by Kiwi Russ, Jan 27, 2004.

  1. Kiwi Russ

    Kiwi Russ Guest

    Reading "A question for Tony T" post, it mentions that entXXX functions
    will disappear eventually, and be replaced by ActiveX (maybe in the next
    realease of Autocad?)
    So my question is how would I convert the 4 samples below to ActiveX?
    I have looked in the vlide help file - but I'm really not sure how to do it.


    1) ((not (setq enaPline (car (entsel "\nSelect polyline : ")))))
    ((/= (cdr (assoc 0 (setq eprPline (entget enaPline)))) "LWPOLYLINE")
    (alert "Selected object is not a polyline.")
    )

    2) (entmod eprPline)

    3) (entupd enaPline)


    4) (entmake '((0 . "Polyline")
    (66 . 1)
    (6 . "Continuous")
    (8 . "Cloud")
    (62 . 256)
    )
    )

    thanks Russ
     
    Kiwi Russ, Jan 27, 2004
    #1
  2. No. I never said or implied that, and it will not
    happen any time soon, because there is way too much
    legacy LISP code that would have to be completely
    rewritten.

    Your code can be converted to ActiveX (although that
    is a bit more than I can delve into now), but if your
    are in a panic about Visual LISP or its (entxxxxx)
    API disappearing, relax.
     
    Tony Tanzillo, Jan 27, 2004
    #2
  3. Kiwi Russ

    Jeff Mishler Guest

    Here's a taste of what it's like, using your samples. Note that this is not
    the only way to do these things, just one that I learned a while back.

    ;selection example
    (defun sel_test (/ doc enaPline pickPnt)
    (setq doc (vla-get-activedocument(vlax-get-acad-object))
    errTest t)
    (while errTest
    (setq errTest
    (vl-catch-all-apply
    '(lambda ()
    (vla-getentity
    (vla-get-utility doc)
    'enaPline 'pickPnt "\nSelect polyline: ")
    )
    )
    )
    (if errTest
    (progn
    (princ (vl-catch-all-error-message errTest))
    (getstring "\nPress enter to continue....")
    )
    )
    )
    (if (not (= (vla-get-objectname enaPline) "AcDbPolyline"))
    (alert "Selected object is not a polyline.")
    ;else it is a pline, carry on.....
    (progn
    ;mod the entity without entmod
    (vla-put-layer enaPline "NewLayer")
    (vla-put-linetype enaPline "ByLayer")
    (vla-put-color enaPline 1)
    ;etc
    ;the following is not always needed, aka entupd
    (vla-update enaPline)
    )
    )
    )
    ;now to create a new LWPolyline
    ; in the following, pass a list of coordinates (x y x y x y)
    (defun makePline (coords / doc newPline)
    (setq doc (vla-get-activedocument(vlax-get-acad-object)))
    (setq newPline (vlax-invoke (vla-get-modelspace doc)
    "AddLightweightPolyline"
    coords))
    (vla-put-layer newPline "Cloud")
    (vla-put-color newPline 256)
    (vla-put-linetype newPline "Continuous")
    (vla-put-closed newPline :vlax-true)
    (princ)
    )

    To create a pline from the above, do something like this:
    (setq plist '(20.0 22.0 20.0 24.0 18.0 24.0 18.0 22.0))
    (makepline plist)

    HTH,
    Jeff
     
    Jeff Mishler, Jan 27, 2004
    #3
  4. Kiwi Russ

    Kiwi Russ Guest

    Tony thanks for clarifying that.

    Jeff
    thanks for the activex conversion...... interesting to see how its done.
    It will be useful for some future programming
    cheers Russ
     
    Kiwi Russ, Jan 28, 2004
    #4
  5. Kiwi Russ

    Joe Burke Guest

    Hi Russ,

    Check the AfraLisp site for vlisp tutorials. Good step-by-step examples of common
    programming tasks.

    http://www.afralisp.com/

    Joe Burke
     
    Joe Burke, Jan 28, 2004
    #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.