Add Custom properties on open file assembly

 

can some one give me a clue why i get this error

 

''ERROR TRYING TO ACCESS PROTECTED MEMORY.

 

THANKS

sERGIO

 

 

 

PrivateSub AddPropertiesNewFile()

Dim objApp As SolidEdgeFramework.Application = Nothing

Dim objAssy As SolidEdgeAssembly.AssemblyDocument = Nothing

objApp = Marshal.GetActiveObject("SolidEdge.Application")

objAssy = objApp.ActiveDocument

Dim objPropertySets As SolidEdgeFileProperties.PropertySets

Dim ObjProperties As SolidEdgeFileProperties.Properties' = Nothing

Dim ObjProperty As SolidEdgeFileProperties.Property = Nothing

 

objPropertySets = objAssy.Properties

ObjProperties = objPropertySets.Item("Custom")'' HERE IS WHERE IT TROWS ME AN ERROR ABOUT PROTECTED MEMORY OR CORRUP MEMORY

ObjProperties.Add("UnitModel", txtModel.Text)

ObjProperties.Add("UnitWidth", Val(txtWidth.Text))

ForEach ObjProperty In ObjProperties

Debug.Print(ObjProperty.Name)

Debug.Print(ObjProperty.Value)

Next

ObjProperties.Save()

objPropertySets.Save()

objAssy.Save()

objPropertySets.Close()

IfNot (objPropertySets IsNothing) Then

Marshal.ReleaseComObject(objPropertySets)

objPropertySets = Nothing

EndIf

IfNot (ObjProperties IsNothing) Then

Marshal.ReleaseComObject(ObjProperties)

ObjProperties = Nothing

EndIf

IfNot (ObjProperty IsNothing) Then

Marshal.ReleaseComObject(ObjProperty)

ObjProperty = Nothing

EndIf

IfNot (objApp IsNothing) Then

Marshal.ReleaseComObject(objApp)

objApp = Nothing

EndIf

IfNot (objAssy IsNothing) Then

Marshal.ReleaseComObject(objAssy)

objAssy = Nothing

EndIf

EndSub

 

Posted by: Sergio Vallejo
Post date: 10/31/2011 4:58:59 AM

2 REPLIES

RE: Add Custom properties on open file assembly

Hi Sergio,

 

you can't use the SolidEdgeFileProperties object on opened Solid Edge documents. Instead you have to use the Properties property of the opened SolidEdgeDocument object.

 

 

Posted by: Wolfgang Kunert
Post date: 10/31/2011 8:55:37 PM

RE: Add Custom properties on open file assembly

Thanks Kupert,

 

that was great after following your tip and chenging my declarations to:

 

Dim objApp As SolidEdgeFramework.Application

Dim objAssy As SolidEdgeAssembly.AssemblyDocument

Dim objPropertySets As SolidEdgeFramework.PropertySets = Nothing

Dim objProperties As SolidEdgeFramework.Properties = Nothing

Dim objProperty As SolidEdgeFramework.Property = Nothing

 

now ia am aable to change/add custom properties to an open file in SE.

 

Thanks! again

Regards

Sergio

 

 

Posted by: Sergio Vallejo
Post date: 11/1/2011 9:18:12 AM