21 | 08 | 2017

Set DWG Custom Properties

Use the code below to specify a drawings custom properties (FILE > DRAWING PROPERTIES) .

{code lang:vbnet lines:false hidden:false}Sub SetCustomDwgProps()

'Lines below set the standard properties
ThisDrawing.SummaryInfo.Author = ThisDrawing.GetVariable("LOGINNAME")
ThisDrawing.SummaryInfo.Comments = "Comments Created by VisibleVisual"
ThisDrawing.SummaryInfo.RevisionNumber = 1
ThisDrawing.SummaryInfo.Title = "VisibleVisual Example"
ThisDrawing.SummaryInfo.Subject = "Entering Properties"
ThisDrawing.SummaryInfo.Keywords = "Example, VBA, Code"

'The lines below create custom properties
Call setCustvalue("PLATFORM", ThisDrawing.GetVariable("PLATFORM"))
Call setCustvalue("COMPUTER", Environ("ComputerName"))
Call setCustvalue("SERIAL", ThisDrawing.GetVariable("_PKSER"))
Call setCustvalue("WEBSITE", "www.visiblevisual.com")
End Sub

'Set Custom Property Value
Sub setCustvalue(key, value)

Dim custvalue As String
Set oSumm = ThisDrawing.SummaryInfo
On Error Resume Next
oSumm.GetCustomByKey key, custvalue
On Error GoTo 0

If custvalue = "" Then
oSumm.AddCustomInfo key, value
oSumm.SetCustomByKey key, value
End If
End Sub{/code}

 The example above gives the following results.



'Dwg Properties Window'
'Dwg Custom Properties Window'

Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles