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

Error loading a Multiline style

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
708 Views, 5 Replies

Error loading a Multiline style

Hi everyone,

Has anybody ever used db.LoadMlineStyleFile() to load a MlineStyle into a
drawing?

I succeeded in loading all styles with a workaround: insert a drawing with
all styles in it. But I think it's more elegant to use mentioned function,
and load only the requested style (instead of all).

db.LoadMlineStyleFile(sMlineStyle, sMlineFile) gives me the error:
eFileAccessErr.

But:
- filename and path are correct (i tried with "\", "\\", "/" and the AutoCAD
search path system)
- the mln file can be found
- the file is not protected or opened in another application
- the filelocation is also not protected
- no problems when manually loading a style from this file (with mlstyle >
Load)

Does anyone have an idea what causes this error eFileAccessErr to appear?

Tnx.
Henk - CAD Accent
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Thank you very much.

Gr Henk
Message 3 of 6
Anonymous
in reply to: Anonymous

I do not know why that exception is generated (I has that error in AutoCAD 2006 and 2007), but this wrapper can help you:
[code]
class Test
{
class Wrapper
{
static int AcadVersion = Autodesk.AutoCAD.ApplicationServices.Application.Version.Major;
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb16.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi,
EntryPoint = "?acdbLoadMlineStyleFile@@YA?AW4ErrorStatus@Acad@@PBD0@Z")]
extern private static ErrorStatus acdbLoadMlineStyleFile16(string mStyle, string mPath);
// For AutoCAD 2007:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode,
EntryPoint = "?acdbLoadMlineStyleFile@@YA?AW4ErrorStatus@Acad@@PB_W0@Z")]
extern private static ErrorStatus acdbLoadMlineStyleFile17(string mStyle, string mPath);
public static ErrorStatus acdbLoadMlineStyleFile(string mStyle, string mPath)
{
switch(AcadVersion)
{
case 16: return acdbLoadMlineStyleFile16(mStyle, mPath);
case 17: return acdbLoadMlineStyleFile17(mStyle, mPath);
}
return ErrorStatus.NotImplementedYet;
}
};

//
// For test only
//
[CommandMethod("T1")]
public static void T1()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ErrorStatus es = Wrapper.acdbLoadMlineStyleFile("METAL", @"F:\Program Files\AutoCAD 2007\ran.mln");
if (es != ErrorStatus.OK)
{
ed.WriteMessage("\nError: {0}", es);
}
}
}
[/code]
Message 4 of 6
Anonymous
in reply to: Anonymous

Hi Alexander, many thanks for the reply.
I will test this wrapper and will here let you know if it worked.

Gr Henk


schreef in bericht
news:5217888@discussion.autodesk.com...
I do not know why that exception is generated (I has that error in AutoCAD
2006 and 2007), but this wrapper can help you:
[code]
class Test
{
class Wrapper
{
static int AcadVersion =
Autodesk.AutoCAD.ApplicationServices.Application.Version.Major;
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb16.dll", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi,
EntryPoint =
"?acdbLoadMlineStyleFile@@YA?AW4ErrorStatus@Acad@@PBD0@Z")]
extern private static ErrorStatus acdbLoadMlineStyleFile16(string
mStyle, string mPath);
// For AutoCAD 2007:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Unicode,
EntryPoint =
"?acdbLoadMlineStyleFile@@YA?AW4ErrorStatus@Acad@@PB_W0@Z")]
extern private static ErrorStatus acdbLoadMlineStyleFile17(string
mStyle, string mPath);
public static ErrorStatus acdbLoadMlineStyleFile(string mStyle, string
mPath)
{
switch(AcadVersion)
{
case 16: return acdbLoadMlineStyleFile16(mStyle, mPath);
case 17: return acdbLoadMlineStyleFile17(mStyle, mPath);
}
return ErrorStatus.NotImplementedYet;
}
};

//
// For test only
//
[CommandMethod("T1")]
public static void T1()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ErrorStatus es = Wrapper.acdbLoadMlineStyleFile("METAL", @"F:\Program
Files\AutoCAD 2007\ran.mln");
if (es != ErrorStatus.OK)
{
ed.WriteMessage("\nError: {0}", es);
}
}
}
[/code]
Message 5 of 6
Anonymous
in reply to: Anonymous

🙂 It is worked because I've tested it before posting.
Message 6 of 6
Anonymous
in reply to: Anonymous

Hi Alexander,

Sorry, for reasons I did'nt have time to implement this in my projects.
But now I did, and you're right, it works very well. Thanks a lot! 🙂

Henk

schreef in bericht
news:5219049@discussion.autodesk.com...
:) It is worked because I've tested it before posting.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost