Author Topic: Shape Files  (Read 3497 times)

0 Members and 1 Guest are viewing this topic.

dukesys

  • Guest
Shape Files
« 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.

Glenn R

  • Guest
Re: Shape Files
« Reply #1 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.

dukesys

  • Guest
Re: Shape Files
« Reply #2 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.

Glenn R

  • Guest
Re: Shape Files
« Reply #3 on: December 07, 2006, 08:20:46 PM »
Try a space Martin...it's hard to tell what it is in the dialog here...

Glenn R

  • Guest
Re: Shape Files
« Reply #4 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.