.NET

Reply
*Henk Loonstra
Message 1 of 6 (261 Views)

Error loading a Multiline style

261 Views, 5 Replies
06-17-2006 03:31 PM
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
*Henk Loonstra
Message 2 of 6 (261 Views)

Re: Error loading a Multiline style

06-24-2006 07:12 AM in reply to: *Henk Loonstra
Thank you very much.

Gr Henk
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 3 of 6 (261 Views)

Re: Error loading a Multiline style

06-24-2006 01:09 PM in reply to: *Henk Loonstra
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]
*Henk Loonstra
Message 4 of 6 (261 Views)

Re: Error loading a Multiline style

06-26-2006 12:18 PM in reply to: *Henk Loonstra
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]
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 5 of 6 (261 Views)

Re: Error loading a Multiline style

06-26-2006 12:54 PM in reply to: *Henk Loonstra
:smileyhappy: It is worked because I've tested it before posting.
*Henk Loonstra
Message 6 of 6 (261 Views)

Re: Error loading a Multiline style

01-17-2007 02:48 PM in reply to: *Henk Loonstra
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...
:smileyhappy: It is worked because I've tested it before posting.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community