Navisworks '25 Custom Properties Crashing (COM API)
Hello,
I have an addin that pulls data from an excel sheet and then uses it to populate custom properties on various model items. It works great in Navis '24, but in Navis '25 I am getting a crash when it tries to run the command "propn.RemoveUserDefined(index)". Did something change in the navis '25 COM API that would be causing this? Or could it have something to do with the changes that were made to the category organization in '25?
Here is a clip of the block that crashes
// Remove existing "PieceTracker" attributes if they exist
int index = 1;
foreach (ComApi.InwGUIAttribute2 attribute in propn.GUIAttributes())
{
if (attribute.UserDefined && attribute.ClassUserName.Equals("PieceTracker"))
{
propn.RemoveUserDefined(index);
break;
}
index++;
}
and here is the whole method
// This method handles updating properties for a found item
private void ProcessModelItem(ModelItem foundItem, ExcelEntry excelEntry, DateTime excelLastModifiedDate)
{
// Convert .NET item to COM
ComApi.InwOpState10 oState = ComApiBridge.State;
ComApi.InwOpSelection comSelectionOut = ComApiBridge.ToInwOpSelection(new ModelItemCollection { foundItem });
foreach (ComApi.InwOaPath3 oPath in comSelectionOut.Paths())
{
ComApi.InwGUIPropertyNode2 propn = (ComApi.InwGUIPropertyNode2)oState.GetGUIPropertyNode(oPath, true);
// Remove existing "PieceTracker" attributes if they exist
int index = 1;
foreach (ComApi.InwGUIAttribute2 attribute in propn.GUIAttributes())
{
if (attribute.UserDefined && attribute.ClassUserName.Equals("PieceTracker"))
{
propn.RemoveUserDefined(index);
break;
}
index++;
}
// Create a new property category
ComApi.InwOaPropertyVec newPvec = (ComApi.InwOaPropertyVec)oState.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwOaPropertyVec, null, null);
// Add properties from Excel data
AddProperty(oState, newPvec, "Mark Number", excelEntry.MarkNumber);
AddProperty(oState, newPvec, "Req Qty Pieces", excelEntry.ReqPieces);
AddProperty(oState, newPvec, "Setup Date", excelEntry.SetupDate);
AddProperty(oState, newPvec, "Req Draw Date", excelEntry.ReqDrawDate);
AddProperty(oState, newPvec, "Req Coord Date", excelEntry.ReqCoordComplete);
AddProperty(oState, newPvec, "Coord Complete Date", excelEntry.CoordComplete);
AddProperty(oState, newPvec, "Coord By", excelEntry.CoordBy);
AddProperty(oState, newPvec, "Mech Complete", excelEntry.MechComplete);
AddProperty(oState, newPvec, "Elec Complete", excelEntry.ElecComplete);
AddProperty(oState, newPvec, "Plumb Complete", excelEntry.PlumbComplete);
AddProperty(oState, newPvec, "Fire Complete", excelEntry.FireComplete);
AddProperty(oState, newPvec, "Arch Complete Date", excelEntry.ArchComplete);
AddProperty(oState, newPvec, "Coord Comments", excelEntry.CoordComments);
AddProperty(oState, newPvec, "Weeks Until Due", excelEntry.WeeksDue);
AddProperty(oState, newPvec, "*Navisworks Last Updated", DateAndTime.Today.ToShortDateString());
AddProperty(oState, newPvec, "*Excel Last Updated", excelLastModifiedDate.ToShortDateString());
// Add the new category to the object
propn.SetUserDefined(0, "PieceTracker", "PieceTracker", newPvec);
}
}
}
Link copied