Custom Properties

Discussion in 'AutoCAD' started by lorier, Oct 20, 2004.

  1. lorier

    lorier Guest

    How do you access custom properties in the properties dialog box?

    TIA
     
    lorier, Oct 20, 2004
    #1
  2. lorier

    Kevin Terry Guest

    If you're using a release prior to 2004, the following:

    'Set custom drawing property
    '
    Public Function TestSetDrawingProperty() As String

    Const DICTIONARY_NAME = "DWGPROPS"

    Dim DwgInfo As AcadXRecord
    Dim DataType As Variant
    Dim Data As Variant
    Dim i As Long
    Dim sType As String, sValue As String
    Dim iType As Integer
    Dim vProp As Variant

    'Title = 0
    'Subject = 1
    'Author = 2
    'Comments = 3
    'Keywords = 4

    On Error GoTo HandleError
    Set DwgInfo = ThisDrawing.Dictionaries(DICTIONARY_NAME)

    DwgInfo.GetXRecordData DataType, Data

    'change title:
    sValue = "Kevin"
    iType = 1
    Data(iType) = sValue
    DwgInfo.SetXRecordData DataType, Data

    'change a custom field (assumes there is a custom field called NAME):
    sType = "NAME"
    sValue = "Kevin"
    For i = LBound(Data) To UBound(Data)
    If DataType(i) >= 300 And DataType(i) <= 309 Then
    If Left(CStr(Data(i)), Len(sType)) = sType Then
    vProp = sType & "=" & sValue
    Data(i) = vProp
    DwgInfo.SetXRecordData DataType, Data
    Exit For
    End If
    End If
    Next

    'look at all of them:
    For i = LBound(Data) To UBound(Data)
    Debug.Print Data(i)
    Next

    Exit Function

    HandleError:

    Set DwgInfo = Nothing

    End Function

    for 2004 & later:
    Public Function SetDrawingProperty(sProp As String, sValue As String) As
    Boolean

    Dim DwgInfo As AcadSummaryInfo
    Dim i As Long
    Dim iNum As Long
    'Dim sKey As String, sValue As String
    Dim sKey As String, sValue2 As String
    Dim bSuccess As Boolean

    On Error GoTo Err_SetDrawingProperty

    Set DwgInfo = ThisDrawing.SummaryInfo

    iNum = DwgInfo.NumCustomInfo

    For i = 1 To iNum
    DwgInfo.GetCustomByIndex i, sKey, sValue2
    If sKey = sProp Then
    DwgInfo.SetCustomByIndex i, sProp, sValue
    bSuccess = True
    Exit For
    End If
    Next

    If Err.Number = 0 Then
    SetDrawingProperty = bSuccess
    Else
    SetDrawingProperty = False
    End If

    Set DwgInfo = Nothing

    Exit Function

    Err_SetDrawingProperty:

    SetDrawingProperty = False

    Set DwgInfo = Nothing

    End Function

    Kevin
     
    Kevin Terry, Oct 20, 2004
    #2
  3. lorier

    lorier Guest

    Thanks, but what I am referring to is the regular old properties dialog window. The one that shows the object type, length, radius, etc.
     
    lorier, Oct 21, 2004
    #3
  4. lorier

    Kevin Terry Guest

    ah sorry bout that...

    Kevin

    window. The one that shows the object type, length, radius, etc.
     
    Kevin Terry, Oct 21, 2004
    #4
  5. lorier

    bcoward Guest

    L,

    Did you ever consider that the "regular old properties" could be the regular properties of the object being displayed? Such as: Object.Name, Object.Top or a concatonation of existing properties etc.

    I've got to be blinded by simplicity because I'm missing the logic in your question. Can you expand for the simple mind?

    Regards,

    Bob Coward
    CADS, Inc

     
    bcoward, Oct 21, 2004
    #5
  6. lorier

    lorier Guest

    hi bob,

    you never explained how to msgbox the filename of a file dragged into autocad... but alas that's another topic

    there are ways to add custom properties to an object through menus. For example I have polyline representing an inlet/catch basin . In the custom properties I have the id#, grate elevation, elevations for the pipes coming in and going out. They show up in my properties window. a list shows that the objects class is 'inlet'. But I don't know how to programmatically get the info stored in these custom properties. Don't even know how to tell how they are stored.

    thanks
     
    lorier, Oct 22, 2004
    #6
  7. I believe that those properties come from a custom object. Only
    creatable from ARX.

    -mjm
     
    michael montagne, Oct 23, 2004
    #7
  8. There are ways to access custom properties that appear
    in the Properties window. But, there are many ways to
    implement custom properties, so you woud need to be
    a bit more specific about what AutoCAD based vertical
    product you're using.
     
    Tony Tanzillo, Oct 23, 2004
    #8
  9. lorier

    lorier Guest

    Civil Series 2004. I discovered the custom properties in the map menu. Sorry Anne for the triple posting. This NG was the only one where I got any response. The custom properties seem really valuable if I can find a way to use them.
     
    lorier, Oct 23, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.