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

How do I change the line type of a line in C#?

2 REPLIES 2
Reply
Message 1 of 3
VirtualCAD
2015 Views, 2 Replies

How do I change the line type of a line in C#?

Hello,

 

I am new to C# and new to .NET for AutoCAD. Trying to do some basic stuff I've done in other APIs.

 

How do I change the line type of a line in C#?

 

I have this line of code that compiles fine:

 

leftLine.Linetype = Autodesk.AutoCAD.GraphicsInterface.Linetype.Dashed.ToString();

 However, on execution, it returns an error with 'eKeyNotFound'.

 

Further, the ToString method has a note in the Visual Studio editor; "This method is obsolete, use System.Enum.Parse(System.Type, System.String);" No luck so far figuring out that one.

 

Thanks in advance for any help.

 

Eric

 

2 REPLIES 2
Message 2 of 3
fenton.webb
in reply to: VirtualCAD

The following code snippet in a C# project shows how to load the linetype from a linestyle file:

 

[CommandMethod("test")]

static public void test()

{

Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

Database db = HostApplicationServices.WorkingDatabase;

Transaction trans = db.TransactionManager.StartTransaction();

try

{

HostApplicationServices.WorkingDatabase.LoadLineTypeFile("DASHED", "acad.lin");

LinetypeTable tbl = (LinetypeTable)trans.GetObject(db.LinetypeTableId,OpenMode.ForRead);

 

ObjectId id = ObjectId.Null;

 

if (true == tbl.Has("DASHED")) id = tbl["DASHED"];

 

ed.WriteMessage("\nDASHED lintype objectid is:" + id.ToString());

trans.Commit();

}

catch

{

}

finally

{

trans.Dispose();

}

}

 

Fenton Webb

Autodesk Developer Network




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 3
bojan_p87
in reply to: fenton.webb

hello fenton webb i need to create linetype "dot(space)continuos(space)dot" - line with space betwen dot and continuos line space ned to be lenght for example 0.25 units i hawe this line of code and its adding new line with name Gline and load it but my problem is i can't create this shape pf line can you help me?

Code:

 

[CommandMethod("Glinija")]
        static public void Glinija()
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Transaction acTrans = acCurDb.TransactionManager.StartTransaction ();
            {
                LinetypeTable acLintypeTbl = acCurDb.LinetypeTableId.GetObject(OpenMode.ForWrite) as LinetypeTable;
                 LinetypeTableRecord Lin = new LinetypeTableRecord();
                Lin.Name = "Glinija";
                Lin.Comments = "Glinija";
                Lin.AsciiDescription = "Line with space froam dot";
              

this i cannot to acomplish i ned "dot,emptySpace,continuos,emptySpace"

 

                acLintypeTbl.Add(Lin);
                acTrans.AddNewlyCreatedDBObject(Lin, true);
                acTrans.Commit();
            }

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

Post to forums  

Autodesk Design & Make Report

”Boost