Physical Model: Script to Delete all 'Extended Properties' from any given Entity and or Attribute

From the Physical Model, using Macro / Script etc:

I need to be able to delete an Extended Property from either an Entity, or an Attribute.

I’d like to do this regardless of if I know the ‘Extended Property’ name or not.

NB I can create a new ‘Extended Properties’ and modify them just fine.

Hi Andrew,

use Delete method of an object. Each object in TDM has Delete method.

Example:

function main(){

var Ent = Model.Entities.GetObject(0);

var i, extProp;

for(i = Ent.ExtendedProperties.Count-1; i>=0; i–)

{

extProp = Ent.ExtendedProperties.GetObject(i);

Log.Information('Extendet property: "' + extProp.Name + '" has been deleted.');

extProp.Delete();

}

}

I hope, this will work for you.

Have a nice day, Michal.

Michal, Your suggestion worked great.

Here is the compete piece of code I used to Delete all Entity Extended Properties, and all associated Attribute Extended Properties.

(First time posting code, so unsure how to format it here).

function Main(){

var App = System.GetInterface(“Application”);

var Model = App.ActiveModel;

var Log = System.CreateObject(“Log”);

DeleteAllExtendedProperties(Model, Log);

}

function DeleteAllExtendedProperties(Model, Log){

var EntityCount; // iterate entities
for (EntityCount=0; EntityCount<Model.Entities.Count; EntityCount++)
{
var curEntity = Model.Entities.GetObject(EntityCount);
DeleteExtendedProperties(curEntity, Log) ;

var AttributeCount; // iterate attributes
for (AttributeCount=0; AttributeCount < curEntity.Attributes.Count; AttributeCount++)
{
var curAttribute = curEntity.Attributes.GetObject(AttributeCount);
DeleteExtendedProperties(curAttribute, Log) ;
}
}
}

function DeleteExtendedProperties(Object, Log)
{
var CountExtendedProperties;
for(CountExtendedProperties = Object.ExtendedProperties.Count-1; CountExtendedProperties>=0; CountExtendedProperties–)
{
var extProp = Object.ExtendedProperties.GetObject(CountExtendedProperties);
extProp.Delete();
}

}

Kind Regards