.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

xref a dxf file

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
2837 Views, 1 Reply

xref a dxf file

Hi,

 

I understand we can only xref a dwg file. It happens to be that sometimes the process doesn't allow us to open dxf and save as dwg, and we only need to read some info in the dxf file before detach it(if we could attach in the first place).

Is there a work around, please? Or I have to write a script to read dxf text? 

 

Thank you very much!

1 REPLY 1
Message 2 of 2
deepak.a.s.nadig
in reply to: Anonymous

It is not possible to attach a DXF file as an external reference.
However, you could write a .NET appplication to read DXF file using "Database.DxfIn" method.
Here is a .NET  sample showing the usage of Database.DxfIn :

 

		[CommandMethod("ReadDxfFile")]
		public void ReadDxfFile() // This method can have any name
		{
			Document doc = Application.DocumentManager.MdiActiveDocument;
			Database db = doc.Database;
			Editor ed = doc.Editor;

			// DXF file to read 
			String dxfFilename = @"C:\temp\Sample.DXF";
			//log file to write the error messages while reading the DXF file
			String logFilename = @"C:\temp\LogSample.log";

			using (Transaction tr = db.TransactionManager.StartTransaction())
			{
				//new database with constructor's buildDefaultDrawing argument set to false
				using (Database Dxfdb = new Database(false, true))
				{
					//function reads the DXF file specified 
					Dxfdb.DxfIn(dxfFilename, logFilename);

					//to insert the contents of DXF file into active drawing
					Matrix3d dxfTrf = Matrix3d.Identity;
					db.Insert(dxfTrf, Dxfdb, true);
					db.UpdateExt(true);
					ViewTableRecord vTable = new ViewTableRecord();
					Point3d minPoint = db.Extmin;
					Point3d maxPoint = db.Extmax;
					Point2d vMax = new Point2d(maxPoint.X, maxPoint.Y);
					Point2d vMin = new Point2d(minPoint.X, minPoint.Y);
					vTable.CenterPoint = vMin + 0.5 * (vMax - vMin);
					vTable.Height = vMax.Y - vMin.Y;
					vTable.Width = vMax.X - vMin.X;
					doc.Editor.SetCurrentView(vTable);
					tr.Commit();
				}
			}
        }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report