vb.net plugin How to change iProperties for virtual part?

vb.net plugin How to change iProperties for virtual part?

Anonymous
Not applicable
1,711 Views
4 Replies
Message 1 of 5

vb.net plugin How to change iProperties for virtual part?

Anonymous
Not applicable

Hello,

 

I`m looking for some help here. I finally learned how to add a virtual part from an excel list to assembly using vb.net plugin. I`d like to know how to change iProperties of the virtual part through vb.net.

 

The iLogic code that I would typically use is:

 

Dim occs As ComponentOccurrences
occs = asmDoc.ComponentDefinition.Occurrences
Dim identity As Matrix
identity = ThisApplication.TransientGeometry.CreateMatrix

Dim virtOcc As ComponentOccurrence If v_qty >= 1 Then virtOcc = occs.AddVirtual(sVirtPart, identity) Try iProperties.Value(sVirtPart & ":1", "Project", "Description") = oProp1 iProperties.Value(sVirtPart & ":1", "Summary", "Title") = oProp1 Catch End Try .......

 so for the plugin I need to re-write this code:

 

Dim _invApp As Inventor.Application

Dim occs As ComponentOccurrences
occs = asmDoc.ComponentDefinition.Occurrences
Dim identity As Matrix identity = _invApp.TransientGeometry.CreateMatrix Dim virtOcc As ComponentOccurrence If vp_qty >= 1 Then virtOcc = occs.AddVirtual(sVirtPart, identity) 'Try ' iProperties.Value(sVirtPart & ":1", "Project", "Description") = oProp1 ' iProperties.Value(sVirtPart & ":1", "Summary", "Title") = oProp1 'Catch 'catch error when oProp1 = nothing 'End Try

 How should I re-write the text in bold , so it works?

 

Any help is appreciated.

Thank you.

Alex.

 

 

 

0 Likes
Accepted solutions (1)
1,712 Views
4 Replies
Replies (4)
Message 2 of 5

Vladimir.Ananyev
Alumni
Alumni

You always may use Inventor APi to set these iProperties.  iProperties of virtual component could be accessed via its VirtualComponentDefinition object.

 

Here is VB .NET sample sub: 

Sub Set_Custom_Property_VirtualComponent( _
         ByVal oOcc As ComponentOccurrence, _
         ByVal PropName As String, _
         ByVal NewValue As String)
 
    Dim VirtualDef As VirtualComponentDefinition _
              = TryCast(oOcc.Definition, VirtualComponentDefinition)
 
    'reference to PropertySet "Inventor User Defined Properties"
    'both methods should work:
 
    'Dim oCustomPropertySet As PropertySet _
    '      = VirtualDef.PropertySets _
    '          .Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
 
    Dim oCustomPropertySet As PropertySet _
          = VirtualDef.PropertySets _
              .Item("Inventor User Defined Properties")
 
    Dim oProperty As Inventor.Property
    Try
        'set new value
        oProperty = oCustomPropertySet.Item(PropName)
        If oProperty.Value.ToString
            oProperty.Value = NewValue
        End If
    Catch ex As Exception
        'add property with new value
        oProperty = oCustomPropertySet.Add(NewValue, PropName)
    End Try
End Sub

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

Vladimir, thank you for your respond.

Yes this is great way to add Custom properties. I appreciate your help.

But how to change predefined iProperties, such as Title in Summary tab, Description in Project tab and so on.

Thank you in advance!

Alex.

0 Likes
Message 4 of 5

Anonymous
Not applicable

I tried the following code which works: for The SUMMARY TAB --> COMPANY only....

 

            Dim VirtualDef As VirtualComponentDefinition = TryCast(virtOcc.Definition, VirtualComponentDefinition)
            Dim summaryPropSet As Inventor.PropertySet
            summaryPropSet = VirtualDef.PropertySets.Item("Inventor Document Summary Information")
            Dim oprop1 As Inventor.Property
            oprop1 = summaryPropSet.Item("Company")
            oprop1.Value = "HellO"

 But if I Use Title instead Company it throws an exeption.... What I really need is to change the Title in Summary tab.

 

also i found out if replace Inventor Document Summary information with

 

summaryPropSet = VirtualDef.PropertySets.Item("Design Tracking Properties")

 

then you can change description.

 

 

thank you.

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

Never mind !  I found solution

 

summaryPropSet = VirtualDef.PropertySets.Item("Summary Information")

 

Thank you!!!!

0 Likes