Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting Custom fields (or other fields) in the DwgProps

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
1179 Views, 14 Replies

Setting Custom fields (or other fields) in the DwgProps

Setting Custom fields (or other fields) in the DwgProps

Custom Tab (Drawing Properties Dialog Box)
Provides ten custom fields for assigning names and values. For example, you
could create a custom field called "Project" and assign the actual project
name as the value. To ensure that all your drawings use the same custom
field names, you could create the custom fields in your drawing templates.
The custom fields can be used in searches to help locate a drawing, such as
when you use the Find dialog box in AutoCAD® DesignCenter™.

AutoCAD also provides access to the properties data using programming
interfaces, such as AutoLISP®.



So how do you set the Custom fields (or other fields) in the DwgProps dialog
though AutoLISP?
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

Maybe this can help:
AsdkOpmX

http://www.contractcaddgroup.com/download/
Message 3 of 15
Anonymous
in reply to: Anonymous

Check out http://www.afralisp.com/newsletter/code/code5.htm.

Steve

"Allen Johnson" wrote in message
news:D9F2916880C7655EF1C121DC3FA34295@in.WebX.maYIadrTaRb...
> Setting Custom fields (or other fields) in the DwgProps
>
> Custom Tab (Drawing Properties Dialog Box)
> Provides ten custom fields for assigning names and values. For example,
you
> could create a custom field called "Project" and assign the actual project
> name as the value. To ensure that all your drawings use the same custom
> field names, you could create the custom fields in your drawing templates.
> The custom fields can be used in searches to help locate a drawing, such
as
> when you use the Find dialog box in AutoCAD® DesignCenterT.
>
> AutoCAD also provides access to the properties data using programming
> interfaces, such as AutoLISP®.
>
>
>
> So how do you set the Custom fields (or other fields) in the DwgProps
dialog
> though AutoLISP?
>
>
Message 4 of 15
Anonymous
in reply to: Anonymous

There is this....

; From: Frank Whaley
; Here is '(getProps)' and '(putProps)', which
; extract Drawing Property data to a set of global
; variables (Title, Subject, etc.) and repack the
; data from the same set of variables.

; Read the DrawingProperties...
(defun getProps ( / xlist val )

(defun val ( dxfCode )
(cdr (assoc dxfCode xlist))
)
; Retrieve Xrecord
(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)
)
)

;------------------------------------------------------------

; Write the DrawingProperties...
(defun putProps ( / xlist )

; Remove any existing Properties
(dictremove (namedobjdict) "DWGPROPS")

; Create data list
(setq xlist (list '(0 . "XRECORD")
'(100 . "AcDbXrecord")
'(1 . "DWGPROPS COOKIE")
(cons 2 Title)
(cons 3 Subject)
(cons 4 Author)
(cons 6 Comments)
(cons 7 Keywords)
(cons 8 LastSavedBy)
(cons 9 RevisionNo)
(cons 300 " ")
(cons 301 " ")
(cons 302 " ")
(cons 303 " ")
(cons 304 " ")
(cons 305 " ")
(cons 306 " ")
(cons 307 " ")
(cons 308 " ")
(cons 309 " ")
(cons 40 (getvar "TDINDWG"))
(cons 41 (getvar "TDCREATE"))
(cons 42 (getvar "TDUPDATE"))
)
)

; Make Xrecord and add to NOD
(dictadd (namedobjdict) "DWGPROPS" (entmakex xlist))
)


--

-Jason
Member of the Autodesk Discussion Forum Moderator Program

> So how do you set the Custom fields (or other fields) in the DwgProps
dialog
> though AutoLISP?
Message 5 of 15
Anonymous
in reply to: Anonymous

Under the Custom tab of the Proerties dialog, I create a field ("Project")
and assign the value "Heartbreak Hotel" to the current drawing. Save and
close then open Acad. When I go to Design Center's Find dialog --- Look for
drawings, then the Drawing tab. Search for the word Heartbreak. But what
category do I select for In the fields category?

Dave P.


"Allen Johnson" wrote in message
news:D9F2916880C7655EF1C121DC3FA34295@in.WebX.maYIadrTaRb...
> Setting Custom fields (or other fields) in the DwgProps
>
> Custom Tab (Drawing Properties Dialog Box)
> Provides ten custom fields for assigning names and values. For example,
you
> could create a custom field called "Project" and assign the actual project
> name as the value. To ensure that all your drawings use the same custom
> field names, you could create the custom fields in your drawing templates.
> The custom fields can be used in searches to help locate a drawing, such
as
> when you use the Find dialog box in AutoCAD® DesignCenterT.
>
> AutoCAD also provides access to the properties data using programming
> interfaces, such as AutoLISP®.
>
>
>
> So how do you set the Custom fields (or other fields) in the DwgProps
dialog
> though AutoLISP?
>
>
Message 6 of 15
Anonymous
in reply to: Anonymous

Thanks all!
Message 7 of 15
Anonymous
in reply to: Anonymous

Why did Frank not resave the custom fields?


"Jason Piercey" wrote in message
news:547805DA27F834F90F562C0F514FE7D1@in.WebX.maYIadrTaRb...
> There is this....
>
> ; From: Frank Whaley
> ; Here is '(getProps)' and '(putProps)', which
> ; extract Drawing Property data to a set of global
> ; variables (Title, Subject, etc.) and repack the
> ; data from the same set of variables.
>
> ; Read the DrawingProperties...
> (defun getProps ( / xlist val )
>
> (defun val ( dxfCode )
> (cdr (assoc dxfCode xlist))
> )
> ; Retrieve Xrecord
> (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)
> )
> )
>
> ;------------------------------------------------------------
>
> ; Write the DrawingProperties...
> (defun putProps ( / xlist )
>
> ; Remove any existing Properties
> (dictremove (namedobjdict) "DWGPROPS")
>
> ; Create data list
> (setq xlist (list '(0 . "XRECORD")
> '(100 . "AcDbXrecord")
> '(1 . "DWGPROPS COOKIE")
> (cons 2 Title)
> (cons 3 Subject)
> (cons 4 Author)
> (cons 6 Comments)
> (cons 7 Keywords)
> (cons 8 LastSavedBy)
> (cons 9 RevisionNo)
> (cons 300 " ")
> (cons 301 " ")
> (cons 302 " ")
> (cons 303 " ")
> (cons 304 " ")
> (cons 305 " ")
> (cons 306 " ")
> (cons 307 " ")
> (cons 308 " ")
> (cons 309 " ")
> (cons 40 (getvar "TDINDWG"))
> (cons 41 (getvar "TDCREATE"))
> (cons 42 (getvar "TDUPDATE"))
> )
> )
>
> ; Make Xrecord and add to NOD
> (dictadd (namedobjdict) "DWGPROPS" (entmakex xlist))
> )
>
>
> --
>
> -Jason
> Member of the Autodesk Discussion Forum Moderator Program
>
> > So how do you set the Custom fields (or other fields) in the DwgProps
> dialog
> > though AutoLISP?
>
>
>
Message 8 of 15
Anonymous
in reply to: Anonymous

I don't know, you will have to ask Frank.

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


> Why did Frank not resave the custom fields?
>
>

> > ; From: Frank Whaley
> > ; Here is '(getProps)' and '(putProps)', which
Message 9 of 15
Anonymous
in reply to: Anonymous

It also crashes (putProps) if you don't have all the global variables
filled.
(does he still work for AutoCAD???)
Message 10 of 15
Anonymous
in reply to: Anonymous

To my (very limited) knowledge yes, he is still employed by Autodesk.

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"Allen Johnson" wrote in message
news:D337713F2ECCA280B4FB911AC0F3CEEB@in.WebX.maYIadrTaRb...
> It also crashes (putProps) if you don't have all the global variables
> filled.
> (does he still work for AutoCAD???)
>
>
Message 11 of 15
Anonymous
in reply to: Anonymous

http://home.pacbell.net/fewhaley/

--
Kevin


"Allen Johnson" wrote in message
news:D337713F2ECCA280B4FB911AC0F3CEEB@in.WebX.maYIadrTaRb...
> It also crashes (putProps) if you don't have all the global variables
> filled.
> (does he still work for AutoCAD???)
>
>
Message 12 of 15
Anonymous
in reply to: Anonymous

Allen Johnson wrote:

>Why did Frank not resave the custom fields?
>
I did. You're not seeing the correct version of 'dwgprops.lsp':

;;
;; dwgprops.lsp
;;
;; This code demonstrates extraction and insertion of Drawing
;; Properties from LISP. Two functions are provided:
;; '(dp-get)' for extracting Properties to global variables, and
;; '(dp-put)' for inserting Properties from those same global
;; variables. Items that are updated by the save reactor are
;; also shown.
;;


(defun dp-get (/ xlist val)
;; shorthand for extraction
(defun val (code)
(cdr (assoc code xlist))
)

;; pick Xrecord from NOD
(setq xlist (dictsearch (namedobjdict) "DWGPROPS"))

;; extract values to global variables
(setq dp:Title (val 2)
dp:Subject (val 3)
dp:Author (val 4)
dp:Comments (val 6)
dp:Keywords (val 7)
dp:LastSavedBy (val 8)
dp:RevisionNo (val 9)
dp:Cust0 (val 300)
dp:Cust1 (val 301)
dp:Cust2 (val 302)
dp:Cust3 (val 303)
dp:Cust4 (val 304)
dp:Cust5 (val 305)
dp:Cust6 (val 306)
dp:Cust7 (val 307)
dp:Cust8 (val 308)
dp:Cust9 (val 309)
)
xlist
)



(defun dp-put (/ xlist safeStr)
;; safe string
(defun safeStr (v)
(if (= 'STR (type v)) v "")
)

;; remove any existing Properties
(dictremove (namedobjdict) "DWGPROPS")

;; make data list
(setq xlist
(list
'(0 . "XRECORD")
'(100 . "AcDbXrecord")
'(1 . "DWGPROPS COOKIE")
(cons 2 (safeStr dp:Title))
(cons 3 (safeStr dp:Subject))
(cons 4 (safeStr dp:Author))
(cons 6 (safeStr dp:Comments))
(cons 7 (safeStr dp:Keywords))
(cons 8 (getvar "loginname"))
(cons 9 (safeStr dp:RevisionNo))
(cons 300 (safeStr dp:Cust0))
(cons 301 (safeStr dp:Cust1))
(cons 302 (safeStr dp:Cust2))
(cons 303 (safeStr dp:Cust3))
(cons 304 (safeStr dp:Cust4))
(cons 305 (safeStr dp:Cust5))
(cons 306 (safeStr dp:Cust6))
(cons 307 (safeStr dp:Cust7))
(cons 308 (safeStr dp:Cust8))
(cons 309 (safeStr dp:Cust9))
(cons 40 (getvar "TDINDWG"))
(cons 41 (getvar "TDCREATE"))
(cons 42 (getvar "TDUPDATE"))
)
)

;; make Xrecord and add to NOD
(dictadd (namedobjdict) "DWGPROPS" (entmakex xlist))
)

;; END of dwgprops.lsp

--
Frank Whaley
Autodesk, Inc.
Message 13 of 15
Anonymous
in reply to: Anonymous

Hi Frank,

Thanks for posting the updated version.

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


> You're not seeing the correct version of 'dwgprops.lsp':
>
> ;;
> ;; dwgprops.lsp
> ;;
> ;; This code demonstrates extraction and insertion of Drawing
> ;; Properties from LISP. Two functions are provided:
> ;; '(dp-get)' for extracting Properties to global variables, and
> ;; '(dp-put)' for inserting Properties from those same global
> ;; variables. Items that are updated by the save reactor are
> ;; also shown.
> ;;
Message 14 of 15
Anonymous
in reply to: Anonymous

It doesn't appear to be able to search the custom fields.
On AcadX website there's a AcadXProps routine that you could program
(through VB) to search the custom fields;
http://code.acadx.com/downloads/002.htm



"Dave Pitzer" wrote in message
news:D8559C664B8C26CC7201655D0D29EE41@in.WebX.maYIadrTaRb...
> Under the Custom tab of the Proerties dialog, I create a field ("Project")
> and assign the value "Heartbreak Hotel" to the current drawing. Save and
> close then open Acad. When I go to Design Center's Find dialog --- Look
for
> drawings, then the Drawing tab. Search for the word Heartbreak. But what
> category do I select for In the fields category?
>
> Dave P.
Message 15 of 15
Anonymous
in reply to: Anonymous

In other words, the HELP file for both Design Center and the DWGPROPS
command are both wrong.

Dave Pitzer
========


"Allen Johnson" wrote in message
news:D9F2916880C7655EF1C121DC3FA34295@in.WebX.maYIadrTaRb...
> Setting Custom fields (or other fields) in the DwgProps
>
> Custom Tab (Drawing Properties Dialog Box)
> Provides ten custom fields for assigning names and values. For example,
you
> could create a custom field called "Project" and assign the actual project
> name as the value. To ensure that all your drawings use the same custom
> field names, you could create the custom fields in your drawing templates.
> The custom fields can be used in searches to help locate a drawing, such
as
> when you use the Find dialog box in AutoCAD® DesignCenterT.
>
> AutoCAD also provides access to the properties data using programming
> interfaces, such as AutoLISP®.
>
>
>
> So how do you set the Custom fields (or other fields) in the DwgProps
dialog
> though AutoLISP?
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report