Author Topic: Custom DwgProps in vba?  (Read 3202 times)

0 Members and 1 Guest are viewing this topic.

Matersammichman

  • Guest
Custom DwgProps in vba?
« on: January 29, 2007, 11:07:02 AM »
Is there a way to create Custom Property Names in vba similar to that defined using the
"-dwgprops" command, "Custom" tab?
I want to create/define my own custom fields with vba (not lisp, vlsp, arx...). :-P

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Custom DwgProps in vba?
« Reply #1 on: January 29, 2007, 11:08:36 AM »
I think youcan modify that tab using vba, let me look to see if I have code for that
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Matersammichman

  • Guest
Re: Custom DwgProps in vba?
« Reply #2 on: January 29, 2007, 11:37:33 AM »
I've got it now Cmdr. Thanks for the help!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Custom DwgProps in vba?
« Reply #3 on: January 29, 2007, 11:49:03 AM »
cool, I just found it, but see you got it already
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Matersammichman

  • Guest
Re: Custom DwgProps in vba?
« Reply #4 on: January 29, 2007, 11:52:09 AM »
What I got was an example from Autocad, but I can easily modify it to work.
Here it is...

    Sub Example_SummaryInfo()
   ' This example shows how to access drawing properties
           
   ' Add and display standard properties
   ThisDrawing.SummaryInfo.Author = "John Doe"
   ThisDrawing.SummaryInfo.Comments = "Includes all ten levels of Building Five"
   ThisDrawing.SummaryInfo.HyperlinkBase = "http://www.autodesk.com"
   ThisDrawing.SummaryInfo.Keywords = "Building Complex"
   ThisDrawing.SummaryInfo.LastSavedBy = "JD"
   ThisDrawing.SummaryInfo.RevisionNumber = "4"
   ThisDrawing.SummaryInfo.Subject = "Plan for Building Five"
   ThisDrawing.SummaryInfo.Title = "Building Five"

   Author = ThisDrawing.SummaryInfo.Author
   Comments = ThisDrawing.SummaryInfo.Comments
   HLB = ThisDrawing.SummaryInfo.HyperlinkBase
   KW = ThisDrawing.SummaryInfo.Keywords
   LSB = ThisDrawing.SummaryInfo.LastSavedBy
   RN = ThisDrawing.SummaryInfo.RevisionNumber
   Subject = ThisDrawing.SummaryInfo.Subject
   Title = ThisDrawing.SummaryInfo.Title
   MsgBox "The standard drawing properties are " & vbCrLf & _
          "Author = " & Author & vbCrLf & _
          "Comments = " & Comments & vbCrLf & _
          "HyperlinkBase = " & HLB & vbCrLf & _
          "Keywords = " & KW & vbCrLf & _
          "LastSavedBy = " & LSB & vbCrLf & _
          "RevisionNumber = " & RN & vbCrLf & _
          "Subject = " & Subject & vbCrLf & _
          "Title = " & Title & vbCrLf

   ' Add and display custom properties
   Dim Key0 As String
   Dim Value0 As String
   Dim Key1 As String
   Dim Value1 As String
   Dim CustomPropertyBranch As String
   Dim PropertyBranchValue As String
   Dim CustomPropertyZone As String
   Dim PropertyZoneValue As String

   CustomPropertyBranch = "Branch"
   PropertyBranchValue = "Main"
   CustomPropertyZone = "Zone"
   PropertyZoneValue = "Industrial"

   ' Add custom properties
   If (ThisDrawing.SummaryInfo.NumCustomInfo >= 1) Then
      ThisDrawing.SummaryInfo.SetCustomByIndex 0, CustomPropertyBranch, PropertyBranchValue
   Else
      ThisDrawing.SummaryInfo.AddCustomInfo CustomPropertyBranch, PropertyBranchValue
   End If

   If (ThisDrawing.SummaryInfo.NumCustomInfo >= 2) Then
       ThisDrawing.SummaryInfo.SetCustomByKey CustomPropertyBranch, "Satellite"
   Else
       ThisDrawing.SummaryInfo.AddCustomInfo CustomPropertyZone, PropertyZoneValue
   End If

   'Get custom properties
   ThisDrawing.SummaryInfo.GetCustomByIndex 0, Key0, Value0
   Key1 = CustomPropertyZone
   ThisDrawing.SummaryInfo.GetCustomByKey Key1, Value1

   MsgBox "The custom drawing properties are " & vbCrLf & _
          "First property name = " & Key0 & vbCrLf & _
          "First property value = " & Value0 & vbCrLf & _
          "Second property name = " & Key1 & vbCrLf & _
          "Second property value = " & Value1 & vbCrLf
End Sub