Jump to content

Accessing CIV3D database in 2016


BIGAL

Recommended Posts

I am having problems now I have installed CIV3D 2016 and this routine gives errors and I do understand the appstr "13.0" may be the wrong number but I seem to be getting errors before I can try a different number. Anyhelp would be appreciated ?

 

;vercheck.lsp  version check for *aecc objects
; By Alan H
(defun ah:vercheck ( / vrsn appstr)
(vl-load-com)

(if ((lambda (vrsn)
       (cond
        ((vl-string-search "R17.2" vrsn) (setq appstr "6.0")) ;09
        ((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;10
        ((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;11
        ((vl-string-search "R18.2" vrsn) (setq appstr "9.0")) ;12 ?
        ((vl-string-search "R19.0" vrsn) (setq appstr "10.0")) ;13 
        ((vl-string-search "R19.1" vrsn)(setq appstr "11.0"));;2014
        ((vl-string-search "R20.0" vrsn)(setq appstr "12.0"));;2015
        ((vl-string-search "R20.1" vrsn)(setq appstr "13.0"));;2016

        ((alert "This version of C3D not supported!"))
       )
      )
      (vlax-product-key)
     )                         ; end if condition progn is true
     (progn
       (cond (*AeccDoc*)
         ((setq *AeccDoc*
           (vlax-get
             (cond (*AeccApp*)
               ((setq *AeccApp*
                 (vla-getinterfaceobject
                    (cond (*Acad*)
                    ((setq *Acad* (vlax-get-acad-object)))
                    )
                    (strcat "AeccXUiLand.AeccApplication." appstr)
                 )
                )
               )
             )
             'ActiveDocument
           )
          )
         )
       ) ; end main cond
     ) ; end progn
) ; end if vsrn
)

Edited by BIGAL
Link to comment
Share on other sites

Where did you get the "11.0", "12.0", and "13.0" from? :unsure:

 

(vl-load-com)

(defun _GetAeccDocument ()
 ((lambda (vrsn)
    (if
      (setq vrsn
             (cond
               ((vl-string-search "20.1" vrsn) "10.5")                 ; 2016
               ((vl-string-search "20.0" vrsn) "10.4")                 ; 2015
               ((vl-string-search "19.1" vrsn) "10.3")                 ; 2014
               ((vl-string-search "19.0" vrsn) "10.0")                 ; 2013
               ((vl-string-search "18.2" vrsn) "9.0")                  ; 2012
               ((vl-string-search "18.1" vrsn) "8.0")                  ; 2011
               ((vl-string-search "18.0" vrsn) "7.0")                  ; 2010
               ((vl-string-search "17.2" vrsn) "6.0")                  ; 2009
               ((vl-string-search "17.1" vrsn) "5.0")                  ; 2008
             )
      )
       (setq *AeccDoc*
              (vlax-get
                (cond (*AeccApp*)
                      ((setq *AeccApp*
                              (vla-getinterfaceobject
                                (cond (*Acad*)
                                      ((setq *Acad* (vlax-get-acad-object)))
                                )
                                (strcat "AeccXUiLand.AeccApplication." vrsn)
                              )
                       )
                      )
                )
                'ActiveDocument
              )
       )
    )

  )
   (if vlax-user-product-key                                           ; If 2013+
     (vlax-user-product-key)                                           ; Use new function
     (vlax-product-key)                                                ; Use legacy function
   )
 )
)

Link to comment
Share on other sites

I don't use Vertical software, but here's how I might write this function FWIW:

(defun _aeccdocument nil
   (cond
       (   *aeccdoc*   )
       (   (setq *aeccdoc* (vlax-get (_aeccapp) 'activedocument)))
   )
)
(defun _aeccapp ( )
   (cond
       (   *aeccapp*   )
       (   (   (lambda ( v )
                   (vl-some
                      '(lambda ( a b ) (if (vl-string-search a v) (setq s b)))
                      '("20.1" "20.0" "19.1" "19.0" "18.2" "18.1" "18.0" "17.2" "17.1")
                      '("10.5" "10.4" "10.3" "10.0"  "9.0"  "8.0"  "7.0"  "6.0"  "5.0")
                   )
               )
               ((eval (cond (vlax-user-product-key) (vlax-product-key))))
           )
           (setq *aeccapp* (vla-getinterfaceobject (_acapp) (strcat "aeccxuiland.aeccapplication." s)))
       )
   )
)
(defun _acapp ( )
   (cond
       (   *acapp*   )
       (   (setq *acapp* (vlax-get-acad-object)))
   )
)

Additional error trapping could be included to account for if the getinterfaceobject method fails, or if the version number is not found:

(defun _aeccdocument nil
   (cond
       (   *aeccdoc*   )
       (   (_aeccapp) (setq *aeccdoc* (vlax-get (_aeccapp) 'activedocument)))
   )
)
(defun _aeccapp ( / err str )
   (cond
       (   *aeccapp*   )
       (   (   (lambda ( v )
                   (not
                       (vl-some
                          '(lambda ( a b ) (if (vl-string-search a v) (setq str b)))
                          '("20.1" "20.0" "19.1" "19.0" "18.2" "18.1" "18.0" "17.2" "17.1")
                          '("10.5" "10.4" "10.3" "10.0"  "9.0"  "8.0"  "7.0"  "6.0"  "5.0")
                       )
                   )
               )
               ((eval (cond (vlax-user-product-key) (vlax-product-key))))
           )
           (prompt "\nIncompatible version.")
       )
       (   (vl-catch-all-error-p
               (setq err
                   (vl-catch-all-apply 'vla-getinterfaceobject
                       (list (_acapp) (strcat "aeccxuiland.aeccapplication." str))
                   )
               )
           )
           (prompt (vl-catch-all-error-message err))
       )
       (   (setq *aeccapp* err))
   )
)
(defun _acapp ( )
   (cond
       (   *acapp*   )
       (   (setq *acapp* (vlax-get-acad-object)))
   )
)

Link to comment
Share on other sites

Please forgive my asking, Lee -

 

I assume that I'm overlooking something, as I do little coding in LISP these days - why is there such a difference in performance between these two (which I *believe* to be equivalent) functions? :unsure:

 

 

 

Sample functions:

 

(defun _Sample1 ()
 ((lambda (v)
    (vl-some
      '(lambda (a b) (if (vl-string-search a v) (setq s b)))
      '("20.1" "20.0" "19.1" "19.0" "18.2" "18.1" "18.0" "17.2" "17.1")
      '("10.5" "10.4" "10.3" "10.0"  "9.0"  "8.0"  "7.0"  "6.0"  "5.0")
      )
    )
   ((eval (cond (vlax-user-product-key) (vlax-product-key))))
   )
)

(defun _Sample2 ()
 ((lambda (vrsn)
    (cond
        ((vl-string-search "20.1" vrsn) "10.5")                        ; 2016
        ((vl-string-search "20.0" vrsn) "10.4")                        ; 2015
        ((vl-string-search "19.1" vrsn) "10.3")                        ; 2014
        ((vl-string-search "19.0" vrsn) "10.0")                        ; 2013
        ((vl-string-search "18.2" vrsn) "9.0")                         ; 2012
        ((vl-string-search "18.1" vrsn) "8.0")                         ; 2011
        ((vl-string-search "18.0" vrsn) "7.0")                         ; 2010
        ((vl-string-search "17.2" vrsn) "6.0")                         ; 2009
        ((vl-string-search "17.1" vrsn) "5.0")                         ; 2008
      )
  )
   (if vlax-user-product-key                                           ; If 2013+
     (vlax-user-product-key)                                           ; Use new function
     (vlax-product-key)                                                ; Use legacy function
   )
 )
)

 

 

 

Results from console:

 

_$ (bench '(_Sample1 _Sample2) '() 10000)

_SAMPLE1 
Elapsed: 563
Average: 0.0563

_SAMPLE2
Elapsed: 47
Average: 0.0047

_$ 

 

 

 

I bumped the iterations up to get non-zero result for _Sample2; admittedly, nobody would do this task that many times on an External Object (which is what this sub-function is intended to support), just curious on performance.

 

Cheers

Link to comment
Share on other sites

Oh, the second function will undoubtedly be quicker: memory is not needing to be allocated to store the two lists supplied to vl-some and there is no eval statement; nevertheless, performance is not a factor for such expressions as they will only ever be evaluated once (as the global variable is referenced thereafter). I simply find lots of repeated expressions make for rather ugly code is all. :)

Link to comment
Share on other sites

Oh, the second function will undoubtedly be quicker: memory is not needing to be allocated to store the two lists supplied to vl-some and there is no eval statement

 

Very good, thank you. :)

Link to comment
Share on other sites

Thanks Blackbox the 20.0 was a typo when I posted from home. The 11 12 13 was a guess as we have only just gone from 2013 to 2016, will try tomorrow when at work. Used for changing contours and point styles via a toolbar rather than toolspace.

Link to comment
Share on other sites

Thanks Blackbox the 20.0 was a typo when I posted from home. The 11 12 13 was a guess as we have only just gone from 2013 to 2016, will try tomorrow when at work. Used for changing contours and point styles via a toolbar rather than toolspace.

 

No worries, my friend; easy fix this time - I'd be interested to see the end result, if/when you're able to share. :thumbsup:

 

Cheers

Link to comment
Share on other sites

Balckbox here is the whole lot zipped up icons, mnu's, docx, you can load the toolbars etc you need to change the contour names in the code to match your style name. I need to redo the icons now with the grey 2016 its become more needed.

 

Chcontourstoolbar.zip

Link to comment
Share on other sites

Just let me know if you have any problems I use it every day, the icons are very average never really got around to making pretty ones. The code problem was "10.5" just changed my Vercheck and works now. Will add the 2013+ bit for future. Thanks for your help finding these versions numbers can be difficult sometimes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...