Get Idw or Dwg Title Block "Description" property

Get Idw or Dwg Title Block "Description" property

isocam
Collaborator Collaborator
1,246 Views
10 Replies
Message 1 of 11

Get Idw or Dwg Title Block "Description" property

isocam
Collaborator
Collaborator

Can anybody help?

 

I am trying to get an "idw" or "dwg" title blocks "DESCRIPTION" property using an Inventor macro.

 

For example, if the description property on a part (ipt) file is "SIDE PLATE", how can I can the same result if the file extension is a "idw" or a "dwg"?

 

Many thanks in advance!!!!

 

IsoCAM

0 Likes
1,247 Views
10 Replies
Replies (10)
Message 2 of 11

Mike.Wohletz
Collaborator
Collaborator

I am guessing that this is an attributed AutoCAD tilte block and not a std Inventor title block? If so let me know as one will be a property and the other you are asking how to read the attributes. 

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

Explain bit more.. Examples or Screen Shot will be good.

 

Sounds it can be solved..

0 Likes
Message 4 of 11

Mike.Wohletz
Collaborator
Collaborator

If you are trying to get this from an attributed block the below should do what you want from inside a managed application. You will need to add the appropriate AutoCAD references to your solution and the proper import statements but I am using something like this everyday to get and set attributed block data. Let me know if you need anything on what references are needed if this is what you are trying to do. 

 

    Public Function GetAcadBlockAttribute(ByVal BlockName As String, ByVal TagName As String) As String
        Dim acadDoc As AcadDatabase = m_inventorApplication.ActiveEditDocument
        For Each Ent As Object In acadDoc.PaperSpace
            If TypeOf Ent Is AcadBlockReference Then
                Dim bRef As AcadBlockReference = Ent
                If bRef.Name.ToUpper = BlockName.ToUpper Then
                    Dim myAtts As Object = Ent.GetAttributes
                    For i = LBound(myAtts) To UBound(myAtts)
                        If myAtts(i).TagString.ToString.ToUpper = TagName.ToUpper Then
                            Return myAtts(i).TextString
                        End If
                    Next
                End If
            End If
        Next
        Return Nothing
    End Function

 

0 Likes
Message 5 of 11

isocam
Collaborator
Collaborator

I am creating either an "IDW" or "DWG" file from an Inventor "IPT" File.

 

I can get the description property for the "IPT" file, using VBA, but I need to get the description property for an "IDW" or "DWG" file that I have open in AutoDesk Inventor (NOT AUTOCAD)

 

Please see the attached screen dump from Inventor.

 

I need to extract the description property using VBA. In the case of the screen dump, this would be...

 

LASER CUT PROFILE - DIE DRIVE END PLATE

 

Many thanks!!!!

 

 

0 Likes
Message 6 of 11

Mike.Wohletz
Collaborator
Collaborator

You would get it just the same as you do from the part. 

 

Sample:

    Public Sub DescriptionProperty()
        Dim DescriptionValue As String = GetProperty(m_InventorApplication.ActiveDocument, "Description")
        'do what you want with this property

    End Sub
    Public Function GetProperty(ByVal oDoc As Inventor.Document, ByVal PropertyName As String) As String
        Try
            Dim oDTP As PropertySet = oDoc.PropertySets.Item("Design Tracking Properties")
            GetProperty = oDTP.Item(PropertyName).Value
        Catch ex As Exception
            Return ""
        End Try
        Return GetProperty
    End Function

 

 

The code I posted before is also for Inventor and not AutoCAD but is for reading attributed AutoCAD blocks in an Inventor drawing. It is all in .NET and not VBA so you will need to do some converting if this is for VBA. 

 

 

0 Likes
Message 7 of 11

isocam
Collaborator
Collaborator

Hi

 

This is the Sub I have on Test

 

Sub GetTitleBlockDescriptionProperty()
    Dim Doc As Document

 

    Set Doc = ThisApplication.ActiveDocument
   
    Dim invDescriptionProperty As Property
      
    Set invDescriptionProperty = Doc.PropertySets.Item("Design Tracking Properties").Item("Description")

 

    Description = UCase$(invDescriptionProperty.Value)
   
    Stop
End Sub

 

I have an Idw file open in inventor. I cannot get the VBA macro to give me the description that is in the title block

 

Can you tell me what I am doing wrong. It runs, but does not give the property "Description"

 

Many Thanks!!!

 

 

0 Likes
Message 8 of 11

Anonymous
Not applicable

This is a snippet that I use to get my drawing's referenced document's description. Sounds like that is maybe what you are trying to do.

 

Dim oDoc As Document

 

If oDoc.DocumentType = kDrawingDocumentObject Then

Dim m_PartDoc As Document
For Each m_PartDoc In oDoc.ReferencedDocuments

sPartDescriptionValue = m_PartDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value

Next

End If

0 Likes
Message 9 of 11

Mike.Wohletz
Collaborator
Collaborator

I just ran the below in a drawing and it returns the description value from the iProperties. is your title block populated from the iProperty "Description"?

 

Sub GetTitleBlockDescriptionProperty()
    Dim Doc As Document
 
    Set Doc = ThisApplication.ActiveDocument
   
    Dim invDescriptionProperty As Property
      
    Set invDescriptionProperty = Doc.PropertySets.Item("Design Tracking Properties").Item("Description")
 Dim Description As String
    Description = UCase$(invDescriptionProperty.Value)
   MsgBox (Description)
   
    Stop
End Sub

 

0 Likes
Message 10 of 11

Anonymous
Not applicable

Yes, that's right. All of our title block fields are linked to the referenced part's iProperties.

0 Likes
Message 11 of 11

xiaodong_liang
Autodesk Support
Autodesk Support

So, you will need to get the document of referenced part, and read its iProperties. just add some more lines, e.g. 

 

Sub GetTitleBlockDescriptionProperty()
    Dim Doc As Document
 
    Set Doc = ThisApplication.ActiveDocument

Dim oPartDoc as PartDocument
Set oPartDoc = Doc.ReferencedDocumentDescriptors(1).ReferencedDocument Dim invDescriptionProperty As Property Set invDescriptionProperty = oPartDoc.PropertySets.Item("Design Tracking Properties").Item("Description") Dim Description As String Description = UCase$(invDescriptionProperty.Value) MsgBox (Description) Stop End Sub

 

 

0 Likes