Skip to content

Commit

Permalink
Update checkXref.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Leoongithub authored Jun 20, 2023
1 parent 70c25b0 commit b516294
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions checkXref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
using System.Data;
using System.Drawing;


using Autodesk.AutoCAD.DatabaseServices;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;




[assembly: SecuredApplication(
@"license")]
//[assembly: SecuredApplication(
//@"license")]

namespace GetFrameOfRealDwg
{
Expand All @@ -32,7 +28,6 @@ public override System.String FindFile(System.String fileName,
Autodesk.AutoCAD.DatabaseServices.FindFileHint hint
)
{

return string.Empty;
}
static public ArrayList GetBlockNames(Database db)
Expand All @@ -45,36 +40,43 @@ static public ArrayList GetBlockNames(Database db)
foreach (ObjectId recordid in bt)
{
BlockTableRecord record = (BlockTableRecord)tran.GetObject(recordid, OpenMode.ForRead);
array.Add(record.Name);
if (record.IsFromExternalReference) {
array.Add("\t" + record.Name + "\t" + record.PathName);
}
}
}
catch
{
}
finally
{
tran.Dispose();
}
return array;
}
static void Main(string[] args)
static int Main(string[] args)
{


MyHostApplicationServices myserver = new MyHostApplicationServices();
int lcid = 0x00001033; // English
int num = 0;
RuntimeSystem.Initialize(myserver, lcid);
Database Db = new Database(false, true);
Db.ReadDwgFile(@"filepath", FileShare.Read, false, "");
ArrayList ar = GetBlockNames(Db);
foreach (string str in ar)
{
System.Console.WriteLine(str);
for (int i = 0; i < args.Length; i++) {
System.Console.WriteLine(args[i]);
Database Db = new Database(false, true);
Db.ReadDwgFile(args[i], FileShare.Read, false, "");
ArrayList ar = GetBlockNames(Db);
if (ar.Count > 0) {
foreach (string str in ar)
{
System.Console.WriteLine(str);
}
num++;
} else {
System.Console.WriteLine("\t无外部参照");
}
System.Console.WriteLine("");
}

RuntimeSystem.Terminate();
System.Console.WriteLine();

return num;
}
}
}

0 comments on commit b516294

Please sign in to comment.