Let's start with the dwg props (custom info object) to get the multiplier for the material.
OK I got a little carried away writing this...
P=
Code:
;___________________________________________________________________________________________________________
;
; CustomInfo Tools Written By; Peter Jamtgaard Copyright 2015
;___________________________________________________________________________________________________________
;
; Function List
; (CustomInfoToList)
; (CustomInfo strKey)
; (CustomInfoPut strKey strValue)
; (CustomInfoAdd strKey strValue)
; (CustomInfoRevove strKey)
; (Errortrap (quote symFunction))
;___________________________________________________________________________________________________________
;
; Function to read the summaryinfo information from the summaryinfo object.
; Returns a list of sublists
; Each sublist includes summary key, index number and value for each key in a sublist.
; Syntax (CustomInfoToList)
; Returns (("PROGRAMMER" 0 "MIKE BOCKOVER") ("DRAWING #" 1 "#") ("REVISION" 2 "A") ) ;<- Abbreviated list
;___________________________________________________________________________________________________________
(defun CustomInfoToList (/
intCustomInfo
lstCustomInfoSublists ; List of Custom Information Pairs
objSummaryInfo
strPValue
strPKey
)
(setq objSummaryInfo (SummaryInfoObject))
(repeat (setq intCustomInfo (vla-NumCustomInfo objSummaryInfo))
(setq intCustomInfo (1- intCustomInfo))
(vla-GetCustomByIndex objSummaryInfo intCustomInfo 'strPKey 'strPValue)
(setq lstCustomInfoSublists (cons (list strPKey intCustomInfo strPValue) lstCustomInfoSublists))
)
)
;___________________________________________________________________________________________________________
; After Notes:
; The SummaryInfo is an object property of the acgivedocumemnt
; The NumCustomInfo is a method of the SummaryInfo object that specifies the number of keys
; The GetCustomByInfo is also a method of the SummaryInfo object that sets a key and its value.
; The CustomInfoSublists is a list of sublists
;___________________________________________________________________________________________________________
;___________________________________________________________________________________________________________
;
; Functions to get summary info object
; Syntax: (SummaryInfoObject)
;___________________________________________________________________________________________________________
(defun SummaryInfoObject ()
(vla-get-summaryinfo
(vla-get-activedocument
(vlax-get-acad-object)))
)
;___________________________________________________________________________________________________________
;
; Function to get summary info value by key.
; Syntax (CustomInfo "PROGRAMMER")
;___________________________________________________________________________________________________________
(defun CustomInfo (strKey)
(if (errortrap (quote (vla-getcustombykey (SummaryInfoObject) (vl-princ-to-string strKey) 'strValue)))
strValue
)
)
;___________________________________________________________________________________________________________
;
; Function to put summary info value by key.
; Syntax (CustomInfoPut "PROGRAMMER" "FRED JONES")
;___________________________________________________________________________________________________________
(defun CustomInfoPut (strKey strValue)
(or
(errortrap (quote (vla-setcustombykey (SummaryInfoObject)
(vl-princ-to-string strKey)
(vl-princ-to-string strValue))))
(CustomInfoAdd strKey strValue)
)
)
;___________________________________________________________________________________________________________
;
; Function to add a new summary info value with key and value
; Syntax (CustomInfoAdd "PROGRAMMER" "FRED JONES")
;___________________________________________________________________________________________________________
(defun CustomInfoAdd (strKey strValue)
(errortrap (quote (vla-AddCustomInfo (SummaryInfoObject)
(vl-princ-to-string strKey)
(vl-princ-to-string strValue))))
)
;___________________________________________________________________________________________________________
;
; Function to add a new summary info value with key and value
; Syntax (CustomInfoRemove "PROGRAMMER")
;___________________________________________________________________________________________________________
(defun CustomInfoRemove (strKey)
(errortrap (quote (vla-RemoveCustomByKey (SummaryInfoObject)
(vl-princ-to-string strKey))))
)
;___________________________________________________________________________________________________________
;
; Function to Trap LISP Errors
;___________________________________________________________________________________________________________
(defun ErrorTrap (symFunction / objError result)
(if (vl-catch-all-error-p
(setq objError (vl-catch-all-apply
'(lambda (X)(set X (eval symFunction)))
(list 'result))))
nil
(if result result 'T)
)
)
(vl-load-com)
;___________________________________________________________________________________________________________
; After Notes:
; The SummaryInfo is an object property of the activedocumemnt
; The NumCustomInfo is a method of the SummaryInfo object that specifies the number of keys
; The GetCustomByInfo is also a method of the SummaryInfo object that sets a key and its value.
; The CustomInfoSublists is a list of sublists
;___________________________________________________________________________________________________________
See two new functions in code box
(CustomInfo "PROGRAMMER") returns the value from the PROGRAMMER custom info
(CustomInfoPut "PROGRAMMER" "FRED JONES") sets the value of the PROGRAMMER custom info to FRED JONES