Error loading a Multiline style

Error loading a Multiline style

Anonymous
Not applicable
1,261 Views
5 Replies
Message 1 of 6

Error loading a Multiline style

Anonymous
Not applicable
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
0 Likes
1,262 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Thank you very much.

Gr Henk
0 Likes
Message 3 of 6

Anonymous
Not applicable
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]
0 Likes
Message 4 of 6

Anonymous
Not applicable
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]
0 Likes
Message 5 of 6

Anonymous
Not applicable
🙂 It is worked because I've tested it before posting.
0 Likes
Message 6 of 6

Anonymous
Not applicable
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.
0 Likes