Post 1 of 3

Define Multileader Style in VB.NET - TextAttachmentType

1011 Views, 2 Replies
02-17-2010 06:09 AM
Hi everyone,

I have a problem, I want to define my multileader styles with a VB.NET subroutine. Prior to VB.NET, I've been using VBA subs and two options we're given to set the text attachment type :

myNewMLeadStyle.TextLeftAttachmentType = 1
myNewMLeadStyle.TextRightAttachmentType = 1

With VB.NET, I can only find this one :

myNewMLeadStyle.TextAttachmentType = TextAttachmentType.AttachmentMiddleOfTop

This line only changes the left text attachment type. How can I change the right one in VB.NET?

Thanks for the help.

Edited by: felixseguin on Oct 6, 2009 5:36 PM
4 Posts
0 Kudos
Registered: ‎03-30-2009
Post 2 of 3

Re: Define Multileader Style in VB.NET - TextAttachmentType

02-18-2010 08:22 AM in reply to: *felixseguin
This is in C#, but all the code is in preperation to run the bottom two lines, which are what actually set the left/right attachment.
mldr = my Mleader Object.

Also, since I'm using AutoCad 2010, the XX's in the partial code next my need to be different depending on your AutoCad version.
[DllImport("acdbXX.dll", ......

I'm pretty sure this come from Tony T., just don't remember.

using System.Runtime.InteropServices;

public enum LeaderDirectionType
UnknownLeader = 0,
LeftLeader = 1,
RightLeader = 2

public static class AcDbMLeaderStyle
public static ErrorStatus SetTextAttachmentType(MLeaderStyle style, TextAttachmentType textAttachmentType, LeaderDirectionType leaderDirection)
return setTextAttachmentType(style.UnmanagedObject, textAttachmentType, leaderDirection);

public static TextAttachmentType GetTextAttachmentType(MLeaderStyle style, LeaderDirectionType leaderDirection)
return getTextAttachmentType(style.UnmanagedObject, leaderDirection);

[DllImport("acdb18.dll", CallingConvention = CallingConvention.ThisCall,
EntryPoint = "?setTextAttachmentType@AcDbMLeaderStyle@@QAE?AW4ErrorStatus@Acad@@W4TextAttachmentType@1@W4LeaderDirectionType@1@@Z")]
private static extern ErrorStatus setTextAttachmentType(IntPtr AcDbMLeaderStylePtr, TextAttachmentType textAttachmentType, LeaderDirectionType leaderDirection);

[DllImport("acdb18.dll", CallingConvention = CallingConvention.ThisCall,
EntryPoint = "?textAttachmentType@AcDbMLeaderStyle@@QBE?AW4TextAttachmentType@1@W4LeaderDirectionType@1@@Z")]
private static extern TextAttachmentType getTextAttachmentType(IntPtr AcDbMLeaderStylePtr, LeaderDirectionType leaderDirection);


AcDbMLeaderStyle.SetTextAttachmentType(mldr, TextAttachmentType.AttachmentMiddleOfTop, LeaderDirectionType.LeftLeader);
AcDbMLeaderStyle.SetTextAttachmentType(mldr, TextAttachmentType.AttachmentMiddleOfBottom, LeaderDirectionType.RightLeader); Edited by: dmcknight@grwinc.com on Feb 18, 2010 4:23 PM
Valued Contributor
62 Posts
0 Kudos
Registered: ‎11-21-2006
Post 3 of 3

Re: Define Multileader Style in VB.NET - TextAttachmentType

06-06-2014 02:09 AM in reply to: *felixseguin

Great solution thanks to all who contributed.

Update for entry points in acdb19.dll


    <DllImport("acdb19.dll", CallingConvention:=CallingConvention.ThisCall, EntryPoint:="?setTextAttachmentType@AcDbMLeaderStyle@@QEAA?AW4ErrorStatus@Acad@@W4TextAttachmentType@1@W4LeaderDirectionType@1@@Z")> _
    Private Shared Function setTextAttachmentType(ByVal AcDbMLeaderStylePtr As IntPtr, ByVal textAttachmentType As TextAttachmentType, ByVal leaderDirection As LeaderDirectionType) As ErrorStatus
    End Function

    <DllImport("acdb19.dll", CallingConvention:=CallingConvention.ThisCall, EntryPoint:="?textAttachmentType@AcDbMLeaderStyle@@QEBA?AW4TextAttachmentType@1@W4LeaderDirectionType@1@@Z")> _
    Private Shared Function getTextAttachmentType(ByVal AcDbMLeaderStylePtr As IntPtr, ByVal leaderDirection As LeaderDirectionType) As TextAttachmentType
    End Function


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!