TheSwamp

Code Red => .NET => Topic started by: dukesys on December 07, 2006, 06:07:00 PM

Title: Shape Files
Post 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.
Title: Re: Shape Files
Post by: Glenn R on December 07, 2006, 07:00:56 PM
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.
Title: Re: Shape Files
Post by: dukesys on December 07, 2006, 07:46:19 PM
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.
Title: Re: Shape Files
Post by: Glenn R on December 07, 2006, 08:20:46 PM
Try a space Martin...it's hard to tell what it is in the dialog here...
Title: Re: Shape Files
Post by: Glenn R on December 07, 2006, 08:34:54 PM
Give this a run 'round the yard:

Code: [Select]
[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.