Slow command extrusion in autocad 2007

Discussion in 'AutoCAD' started by Eramajarvi, Dec 4, 2006.

  1. Eramajarvi

    Eramajarvi Guest

    Does anyone has an answer why it takes so long in Autocad 2007 to
    extrude using the command function?
    I'm just testing autocad 2007 (I normally use R2004,2005,2006) with my
    programming.
    Below you find a testing lisp program. Method 1 = using command
    "extrude" ...
    Method 2 is using vlax-....
    There is no big difference in R2004->2006 in execution time between the
    2 methods. (So why invest in vlax ?)
    In 2007 there is a big difference : vlax = 3 x faster ????

    I've tested this at home with a dell notebook Precision M90 and at work
    with a dell optiplex GX620 both with 2Gb memory, but with different
    graphical cards (M90 = better). In my code below you can find my
    timings.
    The block i've inserted (32 kb) has 2 polylines (first polyline =
    compex profiel and the second one = bounding box = rectangle of the
    first). When anyone wants to test, please replace the name with one of
    your own.
    Is it worthwhile to invest in replacing the classic command function's
    by the vlax ones or can i continue to use the command alternatives ?
    The only difference is notified in R2007. Why ????
    Many thanks to send your vision.

    (defun C:vlaxtst1 (/)

    (vl-load-com)
    (setq *AcadApp* (vlax-get-acad-object))
    (setq *modelspace* (vla-get-modelspace (vla-get-activedocument
    *Acadapp*)))

    (setq path_pt1 (list 100 100 2200) path_pt2 (list 1000 1000 2500))
    (setq sl_pt1l (list 250 150 0) sl_pt2l (list 250 50 0) sl_pt3l (list
    250 150 100)
    sl_pt1r (list 850 1000 0) sl_pt2r (list 850 900 0) sl_pt3r (list 850
    1000 100)
    )

    (command "ucs" "3p" path_pt1 path_pt2 (npt3d path_pt1 0 0 100))
    (command "ucs" "Y" 90.0)
    (command "ucsicon" "on")
    (command "ucsicon" "or")

    (setq number_2_tst 100 block_name "3d_dakal082") ; replace
    "3d_dakal082" with any block containing 1 or more polylines

    (setq ans (ukword 0 "1 2" "Command method(=1),vlax method(=2)" "2"))
    (if (= ans "1") (progn
    (setq start_time (time_hms))
    (repeat number_2_tst
    (command "insert" block_name (list 0 0) "" "" 0)
    (command "explode" (entlast))
    (setq ss_3dpr (ssget "_P") cntr 0)
    (repeat (sslength ss_3dpr)
    (setq poly_ename (ssname ss_3dpr cntr))
    (command "line" (trans path_pt1 0 1) (trans path_pt2
    0 1) "")
    (setq extr_path (entlast))
    (command "extrude" poly_ename "" "path" extr_path)
    (entdel extr_path)
    ' slice
    (command "slice" (entlast) "" "3p" (trans sl_pt1l 0
    1) (trans sl_pt2l 0 1) (trans sl_pt3l 0 1) (trans path_pt2 0 1))
    (command "slice" (entlast) "" "3p" (trans sl_pt1r 0
    1) (trans sl_pt2r 0 1) (trans sl_pt3r 0 1) (trans path_pt1 0 1))
    (setq cntr (1+ cntr))
    )
    )
    (command "ucs" "world")
    (setq end_time (time_hms))
    (getstring (strcat "\nCommand withhod start time = " start_time
    " / ending time = " end_time) " ...")
    ; Dell Notebook Precision M90 R2007 :
    ; 1min 53" with slices
    ; Dell Optiplex GX620 R2007 :
    ; 3min 40" with slices
    ; Dell Optiplex GX620 R2006 :
    ; 1min 05" with slices
    ; Dell Optiplex GX620 R2004 :
    ; 1min 11" with slices
    )
    (progn
    (setq start_time (time_hms))
    (repeat number_2_tst
    (command "insert" block_name (list 0 0) "" "" 0)
    (command "explode" (entlast))
    (setq ss_3dpr (ssget "_P") cntr 0)
    (repeat (sslength ss_3dpr)
    (setq poly_ename (ssname ss_3dpr cntr))

    ; convert polyline to region
    (setq opline (vlax-ename->vla-object poly_ename))

    ; save points polyline to array
    (setq array (list->variant vlax-vbObject (list
    opline)))

    ; make region with polyline points
    (setq oRegion (car (variant->list (vlax-invoke-method
    *modelspace* 'AddRegion array))))
    (setq region_ename (vlax-vla-object->ename oRegion))
    ; delete original polyline
    (vla-delete opline)

    ; extrude along path
    ; define polyline path
    (setq path_ptn (append path_pt1 path_pt2))
    (setq array (list->variant vlax-vbdouble path_ptn))
    (setq oPathPline (vlax-invoke-method *modelspace*
    'Add3Dpoly array))

    (setq oExtrusion (vlax-invoke-method *modelspace*
    'AddExtrudedSolidAlongPath oRegion oPathPline))

    (vla-delete oRegion)
    (vla-delete oPathPline)

    ' slice left
    ; :vlax-false : delete left part
    (vla-slicesolid oExtrusion (vlax-3d-point sl_pt1l)
    (vlax-3d-point sl_pt2l) (vlax-3d-point sl_pt3l) :vlax-false)
    ' slice right
    ; :vlax-true : delete
    (vla-slicesolid oExtrusion (vlax-3d-point sl_pt1r)
    (vlax-3d-point sl_pt2r) (vlax-3d-point sl_pt3r) :vlax-true)
    (vla-delete oExtrusion)
    (setq cntr (1+ cntr))
    )
    )
    (command "ucs" "world")
    (setq end_time (time_hms))

    (getstring (strcat "\nVlax withhod start time = " start_time " /
    ending time = " end_time) " ...")
    ; Dell Notebook Precision M90 R2007 :
    ; 32" with new slices
    ; Dell Optiplex GX620 R2007 :
    ; 55" with new slices
    ; Dell Optiplex GX620 R2006 :
    ; 60" with new slices
    ; Dell Optiplex GX620 R2004 :
    ; 57" with new slices
    )
    )
    )

    ; convert a variant containing a safearray to a list:
    (defun Variant->List (vararray)
    (vlax-safearray->list (variant-value vararray))
    )

    ; Convert a homogenous list to a typed variant array.
    (defun List->Variant (vartype lst)
    ; vartype : vlax-vbinteger vlax-vblong vlax-vbsingle vlax-vbdouble
    ; vlax-vbString vlax-vbobject vlax-vbboolean
    vlax-vbvariant

    (vlax-make-variant
    (vlax-safearray-fill
    (vlax-make-safearray vartype (cons 0 (1- (length
    lst)))) lst)
    )
    )

    (defun ukword (bit kwd msg def / inp)
    (if (and def (/= def "")) ;test for both nil and
    null string
    (setq msg (strcat "\n" msg " <" def ">: ") ;string'em with
    default
    bit (* 2 (fix (/ bit 2))) ;a default and no null bit code
    conflict so
    );setq ;this reduces bit by 1 if odd, to
    allow null
    (setq msg (strcat "\n" msg ": ")) ;without default
    );if
    (initget bit kwd) ;initialize the key
    words
    (setq inp (getkword msg)) ;and use the GET
    command
    (if inp inp def) ;compare the results, return
    appropriate value
    );defun

    (defun time_hms ( / d hr m s)
    (setq d (rtos (getvar "CDATE") 2 6) ;gets Julian date
    hr (substr d 10 2) ;hours
    m (substr d 12 2) ;minutes
    s (substr d 14 2) ;seconds
    );setq
    (strcat hr ":" m ":" s) ;mends together
    );defun
     
    Eramajarvi, Dec 4, 2006
    #1
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.