iLogic: How to create a new PropertySet

iLogic: How to create a new PropertySet

j.pavlicek
Collaborator Collaborator
883 Views
2 Replies
Message 1 of 3

iLogic: How to create a new PropertySet

j.pavlicek
Collaborator
Collaborator

Hello,

I'm trying to create a New PropertySet object where a new properties will be stored during a Rule.

 

But I'm getting following error: Object reference not set to an instance of an object.

 

Tried to declare variable as New, but it causes error (Keyword New cannot be used inside an interface - my translation to EN).

 

 

 

Sub Main()
	Dim iPropSet As PropertySet
	Dim iPropSet2 As PropertySet
		
		'Logger.Debug("SetCustomIprop Sub")
		iPropSet = ThisAssembly.Document.PropertySets("User Defined Properties")
		Logger.Debug(1)
		iPropSet.Add("value", "name")
		Logger.Debug(2)
		iPropSet2.Add("value", "name") '<---Error is here
		Logger.Debug(3)
End Sub

 

 

debug01.png

 

Thanks for advice.

 



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Accepted solutions (2)
884 Views
2 Replies
Replies (2)
Message 2 of 3

marcin_otręba
Advisor
Advisor
Accepted solution

check this out:

https://modthemachine.typepad.com/my_weblog/2010/04/creating-custom-property-sets-and-iproperties.ht...

 

you must do something like

ipropset2=thisassembly.document.propertysets.add(your name)

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 3

j.pavlicek
Collaborator
Collaborator
Accepted solution

Of course, it't obvious, I feel embarrassed. I've must been overworked yesterday.

 

PropertySet is (sub class) of the Document object, which contains its (Document.PropertyClass.Add()). So I need to create this PropertySet as part of some Document object, because it is not defined outside.

 

Public Sub CreatePropertySet()
    ' Get the active document.
    Dim doc As Document
    oDoc = ThisApplication.ActiveDocument

    ' Create a new property set.
    Dim customSet As PropertySet
    myPropertySet = oOoc.PropertySets.Add("My Stuff")

    ' Add a property.
    myPropertySet.Add("Value", "Name")
End Sub

 

Thanks for help!



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes