Issue
I can easily find the filename of the current drawing, but not its ID. Can you help me, please?
Solution
You can find the current PnPProjectDrawing object in the list of the current project's drawings, then get the Id property of this PnPProjectDrawing:
[CommandMethod("FiID")]
public static void FindTheDwgId()
{
Editor ed =Application.DocumentManager.MdiActiveDocument.Editor;
int foundId = -1;
Project prj =PnPProjectUtils.GetProjectPartForCurrentDocument();
System.Collections.Generic.List<PnPProjectDrawing> dwgList =
prj.GetPnPDrawingFiles();
foreach (PnPProjectDrawing dwg in dwgList)
{
ed.WriteMessage(string.Format("\n--Filename: {0}, Id: {1}",
dwg.AbsoluteFileName, dwg.Id));
if( String.Equals( Application.DocumentManager.
MdiActiveDocument.Database.Filename,
dwg.ResolvedFilePath,
StringComparison.InvariantCultureIgnoreCase))
{
foundId = dwg.Id;
break;
}
}
ed.WriteMessage(string.Format(
"\nThe Id of the current drawing is: {0}", foundId));
} // FindTheDwgId()