Convert to ActiveX

Kiwi Russ

Usenet Archive
Joined
Jul 24, 2003
Messages
72
Reaction score
0
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 said:
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?)

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.
 
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
 
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
 

Latest threads

Back
Top