TheSwamp
Code Red => .NET => Topic started by: dukesys on December 07, 2006, 06:07:00 PM
-
Hello All,
Does anybody out there know how to load a shape file using .NET. The only reference I have found to shapes so far, is a property of the TextStyleTableRecord called IsShapeFile. I cannot work out yet how to use this, can anyone help me?
Regards
Martin.
-
It appears that when you manually load a shape file with the "LOAD" command, it creates a new AcDbTextStyleTableRecord/TextStyleTableRecord with a blank name...I just loaded 2 shape files this way.
So you could try creating a new TextStyleTableRecord, give it a blank name and the shx file to use.
Give it a whirl and lert me know how it goes.
Cheers,
Glenn.
-
Glenn,
I tried a blank name, i.e. not setting the .Name value and also setting it to "" and neither works! any other ideas? To explain further why this is important, I am loading in custom linestyles with custom shapes in them.
Cheers
Martin.
-
Try a space Martin...it's hard to tell what it is in the dialog here...
-
Give this a run 'round the yard:
[CommandMethod("ShapeTest")]
static public void ShapeTestCommand( )
{
string shapeFileName = @"C:\Temp\Cfm.shx";
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
TextStyleTable ts = tr.GetObject(db.TextStyleTableId, OpenMode.ForWrite, false) as TextStyleTable;
TextStyleTableRecord tstr = new TextStyleTableRecord();
tstr.FileName = shapeFileName;
tstr.IsShapeFile = true;
ts.Add(tstr);
tr.AddNewlyCreatedDBObject(tstr, true);
tr.Commit();
}
}
Cheers,
Glenn.