Custom Properties Error Check

Discussion in 'AutoCAD' started by dlinford, Dec 3, 2004.

  1. dlinford

    dlinford Guest

    Is there a way to check for a custom Property without getting an error?

    I use the following code to add Custom Properties. But if it already exists it creates another one. If I check to see if it already exists it has an error.

    (vla-AddCustomInfo si "Community" "")
    (vla-AddCustomInfo si "LotNumber" "")
    (vla-AddCustomInfo si "Series" "")

    Any help please.

    David
     
    dlinford, Dec 3, 2004
    #1
  2. dlinford

    John Uhden Guest

    Thanks for helping me learn about SummaryInfo. Hope these quickies are of some
    help...
    (defun GetCustomInfo ( / Info Num Index Custom)
    (and
    (vl-load-com)
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vlax-get *acad* 'ActiveDocument)))
    (vlax-property-available-p *doc* 'SummaryInfo)
    (setq Info (vlax-get *doc* 'SummaryInfo))
    (setq Num (vla-NumCustomInfo Info))
    (setq Index 0)
    (repeat Num
    (vla-getCustomByIndex Info Index 'ID 'Value)
    (setq Custom (cons (cons ID Value) Custom))
    (setq Index (1+ Index))
    )
    )
    (reverse Custom)
    )
    (defun PutCustomInfo (ID Value Index / Info Num)
    (and
    (vl-load-com)
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vlax-get *acad* 'ActiveDocument)))
    (vlax-property-available-p *doc* 'SummaryInfo)
    (setq Info (vlax-get *doc* 'SummaryInfo))
    (setq Num (vla-NumCustomInfo Info))
    (setq Index (max Index 0))
    (if (> Index Num)
    (not (vla-AddCustomInfo Info ID Value))
    (not (vla-SetCustomByIndex Info Index ID Value))
    )
    )
    )

    Since the 2004 help doesn't include anything on SummaryInfo, I had to dig it out
    by:
    (vlax-dump-object SummaryInfo 1)

    2005 is still sitting on my desk from last April, but I never installed it on
    this meager laptop. I hope it includes the missing help topics.



    it creates another one. If I check to see if it already exists it has an error.
     
    John Uhden, Dec 4, 2004
    #2
  3. dlinford

    GaryDF Guest

    Thanks...works great (autocad 2005)
    (PutCustomInfo "Test 1" "#1" 1)
    (PutCustomInfo "Test 2" "#2" 2)

    (GetCustomInfo)

    I added them to my Drawing Properties routine....below.
    Now I can filled out all of the properties.

    Thanks again for your routine.

    Gary







    (defun ARCH:GetProps (/ xlist val)
    (GetCustomInfo)
    ;; shorthand for extraction
    (defun val (gc999) (cdr (assoc gc999 xlist)))
    ;; pick Xrecord from NOD
    (setq xlist (dictsearch (namedobjdict) "DWGPROPS"))
    ;; extract values to variables
    (setq Title (val 2)
    Subject
    (val 3)
    Author (val 4)
    Comments
    (val 6)
    Keywords
    (val 7)
    LastSavedBy
    (val 8)
    RevisionNo
    (val 9)
    Cust0 (val 300)
    Cust1 (val 301)
    Cust2 (val 302)
    Cust3 (val 303)
    Cust4 (val 304)
    Cust5 (val 305)
    Cust6 (val 306)
    Cust7 (val 307)
    Cust8 (val 308)
    Cust9 (val 309))
    xlist)

    (defun ARCH:putProps2004 (/ xlist lognam datst crdate dwginfo)
    ;;(PutCustomInfo "Test 1" "#1" 1)
    ;;(PutCustomInfo "Test 2" "#2" 2)

    (cond ((= (getvar "loginname") "cad_11") (setq lognam "FWP"))
    ((or (= (getvar "loginname") "cad-41")
    (= (getvar "loginname") "Gary Davidson Fowler"))
    (setq lognam "GDF"))
    ((= lognam nil) (setq lognam (getvar "loginname"))))
    (setq DATST (rtos (getvar "CDATE") 2 16)
    CRDATE (substr DATST 1 4))
    (setq dwginfo (vla-get-summaryinfo (vla-get-activedocument
    (vlax-get-acad-object))))
    (vlax-put-property
    dwginfo
    'Author
    "ARCHITETTURA, Inc. [www.architettura-inc.com]")
    (vlax-put-property dwginfo 'Comments commentx)
    (vlax-put-property dwginfo 'Keywords (ARCH:Basename (getvar "dwgname")))
    (vlax-put-property
    dwginfo
    'Subject
    (strcat "File Name : " (getvar "dwgname") " [©" CRDATE "]"))
    (vlax-put-property dwginfo 'Title (getvar "dwgprefix"))
    (princ))

    ;;;;;;;;;;;;;;;;;;;;;;;;;; Record Xref to Drawing Properties
    ;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; --- get properties, grab refs, update properties
    (defun XREFPROP-NEW (/ 1st commentx)
    (setq lst (ARCH:XREF_LIST))
    (cond ((= lst nil)
    (progn (setq str "Created using : Arch Program© for AutoCAD®")
    (setq commentx str)
    (ARCH:putProps2004)
    (princ "\n*** ----- Drawing Properties Updated ----- ***")))
    ((/= lst nil)
    (progn (setq str "")
    (foreach
    itm lst
    (setq str (strcat str itm))
    (if (/= itm (last lst))
    (setq str (strcat str (chr 13) (chr 10)))))
    (if (<= (strlen str) 4096)
    (progn (setq commentx str)
    (ARCH:putProps2004)
    (princ "\n*** ----- Drawing Properties Updated -----
    ***"))))))
    (princ))
     
    GaryDF, Dec 6, 2004
    #3
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.