- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
Can anyone check below i-logic code?
=============================
Dim propertyName1 As String = "Rev Desc" Dim propertyValue1 As String = "" customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try prop = customPropertySet.Item(propertyName1) Catch customPropertySet.Add("", propertyName1) End Try Dim propertyName2 As String = "Rev Date" Dim propertyValue2 As String = "mm/dd/yyyy" customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try prop = customPropertySet.Item(propertyName2) Catch customPropertySet.Add("mm/dd/yyyy", propertyName2) End Try Dim propertyName3 As String = "Salvagnini Proficient" Dim propertyValue3 As String = "Yes" customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try prop = customPropertySet.Item(propertyName3) Catch customPropertySet.Add("Yes/No", propertyName3) End Try
====================================================
The problem on the result i have is the "Rev Date" shown as text meanwhile the purpose i need is "Date"
and the 2nd one on string "Salvagnini proficient" it's needs to be a multpile choices 'YES'NO"
Please see attached the wrong result and what i need.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You must use a value of the datatype expected by the property type you want it to be.
For example, if you want a date property, the value must be of a date type.
Dim propertyName1 As String = "Rev Desc" Dim propertyValue1 As String = "" Dim customPropertySet As PropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try prop = customPropertySet.Item(propertyName1) Catch customPropertySet.Add("", propertyName1) End Try Dim propertyName2 As String = "Rev Date" Dim propertyValue2 As Date = Today.Date Try prop = customPropertySet.Item(propertyName2) Catch customPropertySet.Add(propertyValue2, propertyName2) End Try Dim propertyName3 As String = "Salvagnini Proficient" Dim propertyValue3 As Boolean = True Try prop = customPropertySet.Item(propertyName3) Catch customPropertySet.Add(propertyValue3, propertyName3) End Try
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Pulled directly from the API help file.
Public Sub CreateCustomProperties()
' Get the active document.
Dim invDoc As Document
Set invDoc = ThisApplication.ActiveDocument
' Get the user defined (custom) property set.
Dim invCustomPropertySet As PropertySet
Set invCustomPropertySet = invDoc.PropertySets.Item("Inventor User Defined Properties")
' Declare some variables that will contain the various values.
Dim strText As String
Dim dblValue As Double
Dim dtDate As Date
Dim blYesOrNo As Boolean
' Set values for the variables.
strText = "Some sample text."
dblValue = 3.14159
dtDate = Now
blYesOrNo = True
' Create the properties.
Dim invProperty As Property
Set invProperty = invCustomPropertySet.Add(strText, "Test Test")
Set invProperty = invCustomPropertySet.Add(dblValue, "Test Value")
Set invProperty = invCustomPropertySet.Add(dtDate, "Test Date")
Set invProperty = invCustomPropertySet.Add(blYesOrNo, "Test Yes or No")
End Sub
For a yes/no custom iProperty you will need to provide a variable with a boolean type.
Best of luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@Anonymous You have provided an example that runs VBA makro and you are trying to write it to iLogic. As a result, you get an error. Replace "Public Sub CreateCustomProperties ()" with "Sub main ()". And everywhere there is the word “Set”. Erase them.
And just read all @JhoelForshav posts in this forum and you will find a lot of interesting and useful ![]()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
Just come up with another question, what string do i have to put on "Rev Date" if i want it to leave empty on the first entry value, so it will be filled when we do the revision.
Dim propertyName2 As String = "Rev Date" Dim propertyValue2 As Date =Today.Date
Attached the final result that i wanted.
Appreciated your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
Thanks for your correction, would you please take a look to my latest reply? on "Rev Date" i want it to leave empty on the first entry value, so it will be filled when we do the revision.
I have attached on replied with the pic that i wanted.
Appreciated your prompt reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Do you use code written by @JhoelForshav ?
He will stop sleeping and write you an answer. If you're having trouble waiting, ![]()
try changing
"Dim propertyValue2 As Date = Today.Date"
to Dim DimValue2 As Date = " "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Rob
sorry for hurry, he is sleeping and will read by tomorrow, so do i.
Anyway i tried with your suggestion and it looks like the string did not match,
See Attached
Thank You very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The only way I can get this to work is to create the property with a date, then make it Null. Like this ![]()
Dim propertyName1 As String = "Rev Desc" Dim propertyValue1 As String = "" Dim customPropertySet As PropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try prop = customPropertySet.Item(propertyName1) Catch customPropertySet.Add("", propertyName1) End Try Dim propertyName2 As String = "Rev Date" Dim propertyValue2 As Nullable(Of Date) = Date.Now Dim NullDate As Nullable(Of Date) Try prop = customPropertySet.Item(propertyName2) Catch customPropertySet.Add(propertyValue2, propertyName2) iProperties.Value("Custom", propertyName2) = NullDate End Try Dim propertyName3 As String = "Salvagnini Proficient" Dim propertyValue3 As Boolean = True Try prop = customPropertySet.Item(propertyName3) Catch customPropertySet.Add(propertyValue3, propertyName3) End Try
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Waw,,.. Its working now,
Thank You very much sir, have a good day
God bless you