Creating a custom iProperty in a Virtual Component

Creating a custom iProperty in a Virtual Component

jhunt3Z5BG
Participant Participant
1,186 Views
2 Replies
Message 1 of 3

Creating a custom iProperty in a Virtual Component

jhunt3Z5BG
Participant
Participant

I have been trying to create a custom iProperty in a Virtual Component (via iLogic) and have hit the wall. I know how to change the standard VC iProperties and create iProperties in a standard part via iLogic, but cant do it in a VC.

 

Here is a simpler version of my test code: Can anyone helpp me? I believe the issue is this part of the code below: "customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")", as this is setting the value in the assembly level by definition, not the VC.

 

'--------------------------------------Start of iLogic

'--------------------------------------Check that we are in an Assembly
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject Then
MessageBox.Show("You must be in an Assembly to run this rule!")
Return
End If


Dim oAssDef As AssemblyComponentDefinition 
oAssDef = oDoc.ComponentDefinition 
Dim oMatrix As Matrix 

oMatrix = ThisApplication.TransientGeometry.CreateMatrix
NameOfVirtualPart = "TEST"
'--------------------------------------Add one virtual occurrence 
Dim oNewOcc As ComponentOccurrence 
oNewOcc = oAssDef.Occurrences.AddVirtual(NameOfVirtualPart, oMatrix) 
Dim oCVirtualCompDef As VirtualComponentDefinition 
oCVirtualCompDef = oNewOcc.Definition

'--------------------------------------Standard iProperties Populated
iProperties.Value(oCVirtualCompDef, "Project", "Description") = GoExcel.CellValue("AutoCAD Attributes.xls", "Summary", "B2")

'--------------------------------------Define Variable to Shorten Code Text Length
customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")

'--------------------------------------Check for Custom iProperties and add them if not found
'--------------------------------------Define iProperty Names as a String
Dim PropertyName1 As String = "FAMILY"


'--------------------------------------Adding Custom "CISCO_PART_\U+0023_FOR_ERP" iProperty
Try
          prop = customPropertySet.Item(PropertyName1)
Catch
          customPropertySet.Add("", PropertyName1)
End Try


''--------------------------------------Populate "FAMILY" iProperty
iProperties.Value(NameOfVirtualPart, "Custom", "NUMB") = "TEST" 'GoExcel.CellValue("AutoCAD Attributes.xls", "Summary", "E2")

 

0 Likes
Accepted solutions (1)
1,187 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

you can try it like this:

Dim oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
    MessageBox.Show("You must be in an Assembly to run this rule!")
    Return
End If


Dim oAssDef As AssemblyComponentDefinition
oAssDef = oDoc.ComponentDefinition
Dim oMatrix As Matrix

oMatrix = ThisApplication.TransientGeometry.CreateMatrix
Dim NameOfVirtualPart = "TEST"
'--------------------------------------Add one virtual occurrence 
Dim oNewOcc As ComponentOccurrence = oAssDef.Occurrences.AddVirtual(NameOfVirtualPart, oMatrix)
Dim oCVirtualCompDef As VirtualComponentDefinition = oNewOcc.Definition

'--------------------------------------Standard iProperties Populated
iProperties.Value(oCVirtualCompDef, "Project", "Description") = "my test" ' GoExcel.CellValue("AutoCAD Attributes.xls", "Summary", "B2")

Dim customSet = oCVirtualCompDef.PropertySets.Item("Inventor User Defined Properties")

Try
    Dim prop As [Property] = customSet.Item("NUMB")
    prop.Value = "TEST"
Catch ex As Exception
    customSet.Add("TEST", "NUMB")
End Try

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

jhunt3Z5BG
Participant
Participant

@JelteDeJong This is awesome...didn't think of trying it this way!

0 Likes