Inventor Customization

Reply
Member
freece-cl
Posts: 3
Registered: ‎03-15-2011
Message 1 of 5 (1,694 Views)
Accepted Solution

ilogic create custom ipropertie

1694 Views, 4 Replies
03-15-2011 12:24 PM

Hello

 

I would like to create an new custom ipropertie with ilogic.

The reason is the contentcenter, thei haven't custom iproperties.

 

How should the code work:

if

propertie "test" is available

write the value in the propertie

else if

propertie test isn't available

create prpertie

write the value in the propertie

end if

 

How can i check if the propertie is already exists in the file?

How can i create a new custom iPropertie?

How solves other this problem?

 

The rest of teh code is ready and works fine.

 

i've faund already some code with VBA but not with "pure" ilogic.

 

Thanks and Greetings Daniel

 

 

 

 

Where are you going to put the iLogic rule to create the custom iProperty?  Will you put it in the Content Center part or in the assembly?  If it's in the assembly, how will it find the Content Center part and when will the rule run?

 

Here's some code to create a custom iProperty in a part, if it is not found:

 

Dim propertyName As String = "MyProperty"
Dim propertyValue as String = "Test Value"
customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
prop = customPropertySet.Item(propertyName)
Catch
' Assume error means not found
customPropertySet.Add("", propertyName)
End Try
iProperties.Value("Custom", propertyName) = propertyValue

 

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 2 of 5 (1,684 Views)

Re: ilogic create custom ipropertie

03-15-2011 07:33 PM in reply to: freece-cl

Where are you going to put the iLogic rule to create the custom iProperty?  Will you put it in the Content Center part or in the assembly?  If it's in the assembly, how will it find the Content Center part and when will the rule run?

 

Here's some code to create a custom iProperty in a part, if it is not found:

 

Dim propertyName As String = "MyProperty"
Dim propertyValue as String = "Test Value"

customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
      prop = customPropertySet.Item(propertyName)
Catch
      ' Assume error means not found
      customPropertySet.Add("", propertyName)
End Try

iProperties.Value("Custom", propertyName) = propertyValue

 

 



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Member
freece-cl
Posts: 3
Registered: ‎03-15-2011
Message 3 of 5 (1,682 Views)

Re: ilogic create custom ipropertie

03-15-2011 10:59 PM in reply to: freece-cl

Hello Mike

 

Thanks for your answer.

 

I'd like to have an external rule.The user can start it,  and fill in the values of the properties.

The templates have already the custom iproperties, but the contencenterfiles (profile) not.

So I need the rule to check if the propertie is there, if not so I have to create it, and fill in the value.

 

I will check your code in the next days.

 

Thank you, for your fast answer.

Daniel

Member
freece-cl
Posts: 3
Registered: ‎03-15-2011
Message 4 of 5 (1,584 Views)

Re: ilogic create custom ipropertie

04-06-2011 01:03 PM in reply to: MjDeck

Hello Mike

 

I've checked your code and it works fine. Thank you.

I' ve use it as a external rule, wich the user can start manually.

 

The missing iProperties can now add easily.

 

Greetings Daniel 

Valued Contributor
thomas.fitzgerald
Posts: 53
Registered: ‎08-02-2006
Message 5 of 5 (1,045 Views)

Re: ilogic create custom ipropertie

10-10-2012 10:41 AM in reply to: freece-cl

Heres an updated version using a loop to populate multiple custom iproperties.  it also gives you an opportunity to fill in the property if its "null".

 

customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")

Dim iprop(5) As String
iprop(1) = "Part Number"
iprop(2) = "Cage Code"
iprop(3) = "Material"
iprop(4) = "Material Specification"
iprop(5) = "MSSv(part) Description"

For k = 1 To 5
Dim prop(k) As String
Try
prop(k) = iProperties.Value("Custom", iprop(k))
Catch
'Assume error means not found
customPropertySet.Add("", iprop(k))
iProperties.Value("Custom", iprop(k)) = "null"
End Try
Next

For j = 1 To 5
Dim var(j) As String
If iProperties.Value("Custom", iprop(j)) = "null" Then
var(j) = InputBox("A value is needed for iProperty: " & iprop(j), "Warning", "")
iProperties.Value("Custom", iprop(j)) = var(j)
End If
Next


Thomas Fitzgerald
Technical Consultant
Autodesk Consulting
262.422.2519
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.