(SetCustomDwgProp "Pages" "1")
Will add only if necessary then set the Custom Property "n_project" to "IT.19.9655" using the following code.
(defun getCustomDwgProp (key / app doc dwgprops try val)
(vl-load-com)
(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
DwgProps (vla-Get-SummaryInfo Doc)
)
(cond
((vl-catch-all-error-p
(setq try (vl-catch-all-apply
'vla-GetCustomByKey
(list DwgProps key 'val)
)
)
)
(setq val nil)
)
)
val
)
(defun SetCustomDwgProp (key value / App Doc DwgProps)
(vl-load-com)
(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
DwgProps (vla-Get-SummaryInfo Doc)
)
(if (getCustomDwgProp key)
(vla-SetCustomByKey DwgProps key value)
(vla-AddCustomInfo DwgProps key value)
)
)