Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add a Property

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
177 Views, 2 Replies

Add a Property

I have a PropertySet set up. I am wanting to check them by name, and if
they do not exist, add them. The code is below. At the ninth and tenth
lines below, how can I add the properties back in?

Thanks for the help....



Private Sub ChkUserProp()
Dim oPropNew As Property

' Use existing oProp4 to add properties if they do not exist (oProp4 has
not been initially defined in other sub)
Set oProp4 =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
2CF9AE}")

' Delete Properties Example
For Each oPropNew In oProp4
oProp4(1).Delete
Next

' Re-add Properties Example ???
Call oProp4(1).Add("Test", "Finish")




' If oPropNew.Name <> "Finish" Then
' Call oPropNew.Add("Test", "Finish", 1)
' End If

' If oProp4.ItemByPropId.Value <> "MAT'L CODE" Then
' oProp4(2).Add "MAT'L CODE"
' End If

' If oProp4.ItemByPropId.Value <> "MATERIAL" Then
' oProp4(3).Add "MATERIAL"
' End If

' If oProp4.ItemByPropId.Value <> "SUB NO." Then
' oProp4(4).Add "SUB NO."
' End If

' If oProp4.ItemByPropId.Value <> "MFG CODE" Then
' oProp4(5).Add "MFG CODE"
' End If

' If oProp4.ItemByPropId.Value <> "RSP" Then
' oProp4(6).Add "RSP"
' End If

End Sub
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

I figured out how to add the properties. The problem is that they default
to "TEXT" fot type. How is this information changed to the other types?
Such as Yes No?

Dim oPropNew As Property

' Use existing oProp4 to add properties if they do not exist (oProp4 has
not been initially defined in other sub)
Set oProp4 =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
2CF9AE}")

' Delete Properties Example
For Each oPropNew In oProp4
oProp4(1).Delete
Next

' Re-add Properties Example
Set oPropNew = oProp4.Add("", "Finish")
Set oPropNew = oProp4.Add("", "MAT'L CODE")
Set oPropNew = oProp4.Add("", "MATERIAL")
Set oPropNew = oProp4.Add("", "SUB NO.")
Set oPropNew = oProp4.Add("", "MFG CODE")
Set oPropNew = oProp4.Add("", "RSP")



"Steve Anderson" wrote in message
news:47F79050684E2B8E55BCD7D9A83D2F25@in.WebX.maYIadrTaRb...
> I have a PropertySet set up. I am wanting to check them by name, and if
> they do not exist, add them. The code is below. At the ninth and tenth
> lines below, how can I add the properties back in?
>
> Thanks for the help....
>
>
>
> Private Sub ChkUserProp()
> Dim oPropNew As Property
>
> ' Use existing oProp4 to add properties if they do not exist (oProp4
has
> not been initially defined in other sub)
> Set oProp4 =
>
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> 2CF9AE}")
>
> ' Delete Properties Example
> For Each oPropNew In oProp4
> oProp4(1).Delete
> Next
>
> ' Re-add Properties Example ???
> Call oProp4(1).Add("Test", "Finish")
>
>
>
>
> ' If oPropNew.Name <> "Finish" Then
> ' Call oPropNew.Add("Test", "Finish", 1)
> ' End If
>
> ' If oProp4.ItemByPropId.Value <> "MAT'L CODE" Then
> ' oProp4(2).Add "MAT'L CODE"
> ' End If
>
> ' If oProp4.ItemByPropId.Value <> "MATERIAL" Then
> ' oProp4(3).Add "MATERIAL"
> ' End If
>
> ' If oProp4.ItemByPropId.Value <> "SUB NO." Then
> ' oProp4(4).Add "SUB NO."
> ' End If
>
> ' If oProp4.ItemByPropId.Value <> "MFG CODE" Then
> ' oProp4(5).Add "MFG CODE"
> ' End If
>
> ' If oProp4.ItemByPropId.Value <> "RSP" Then
> ' oProp4(6).Add "RSP"
> ' End If
>
> End Sub
>
>
Message 3 of 3
Anonymous
in reply to: Anonymous

The values of properties are actually Variants which means it can represent
many different types. You define the type implicitly by the type of input
value used in the assignment. Here's a modified version of the portion of
your code where you're creating the properties. The "Finish" property will
be a Yes/No since I'm setting it using a Boolean value. The "Sub No." will
be a number because I'm setting it with a number. I could also use a
variable that is Integer, Long, or Double type to create a number property.
The "RSP" property will be a date because it is set using a date value.

' Re-add Properties Example
Set oPropNew = oProp4.Add(True, "Finish")
Set oPropNew = oProp4.Add("", "MAT'L CODE")
Set oPropNew = oProp4.Add("", "MATERIAL")
Set oPropNew = oProp4.Add(0, "SUB NO.")
Set oPropNew = oProp4.Add("", "MFG CODE")
Set oPropNew = oProp4.Add(Now, "RSP")
--
Brian Ekins
Developer Technical Services, Autodesk
Discussion Q&A: http://www.autodesk.com/discussion


"Steve Anderson" wrote in message
news:5DFEECFA0F26CB1364C2D6A7F9AC9572@in.WebX.maYIadrTaRb...
> I figured out how to add the properties. The problem is that they default
> to "TEXT" fot type. How is this information changed to the other types?
> Such as Yes No?
>
> Dim oPropNew As Property
>
> ' Use existing oProp4 to add properties if they do not exist (oProp4
has
> not been initially defined in other sub)
> Set oProp4 =
>
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> 2CF9AE}")
>
> ' Delete Properties Example
> For Each oPropNew In oProp4
> oProp4(1).Delete
> Next
>
> ' Re-add Properties Example
> Set oPropNew = oProp4.Add("", "Finish")
> Set oPropNew = oProp4.Add("", "MAT'L CODE")
> Set oPropNew = oProp4.Add("", "MATERIAL")
> Set oPropNew = oProp4.Add("", "SUB NO.")
> Set oPropNew = oProp4.Add("", "MFG CODE")
> Set oPropNew = oProp4.Add("", "RSP")
>
>
>
> "Steve Anderson" wrote in message
> news:47F79050684E2B8E55BCD7D9A83D2F25@in.WebX.maYIadrTaRb...
> > I have a PropertySet set up. I am wanting to check them by name, and if
> > they do not exist, add them. The code is below. At the ninth and tenth
> > lines below, how can I add the properties back in?
> >
> > Thanks for the help....
> >
> >
> >
> > Private Sub ChkUserProp()
> > Dim oPropNew As Property
> >
> > ' Use existing oProp4 to add properties if they do not exist (oProp4
> has
> > not been initially defined in other sub)
> > Set oProp4 =
> >
>
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> > 2CF9AE}")
> >
> > ' Delete Properties Example
> > For Each oPropNew In oProp4
> > oProp4(1).Delete
> > Next
> >
> > ' Re-add Properties Example ???
> > Call oProp4(1).Add("Test", "Finish")
> >
> >
> >
> >
> > ' If oPropNew.Name <> "Finish" Then
> > ' Call oPropNew.Add("Test", "Finish", 1)
> > ' End If
> >
> > ' If oProp4.ItemByPropId.Value <> "MAT'L CODE" Then
> > ' oProp4(2).Add "MAT'L CODE"
> > ' End If
> >
> > ' If oProp4.ItemByPropId.Value <> "MATERIAL" Then
> > ' oProp4(3).Add "MATERIAL"
> > ' End If
> >
> > ' If oProp4.ItemByPropId.Value <> "SUB NO." Then
> > ' oProp4(4).Add "SUB NO."
> > ' End If
> >
> > ' If oProp4.ItemByPropId.Value <> "MFG CODE" Then
> > ' oProp4(5).Add "MFG CODE"
> > ' End If
> >
> > ' If oProp4.ItemByPropId.Value <> "RSP" Then
> > ' oProp4(6).Add "RSP"
> > ' End If
> >
> > End Sub
> >
> >
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report