Just in case someone else needs this...
Essentially it's just a wrapper round some MFC code. The mixed managed code
is just to prove it works.
Thanks to Alexander Rivilis for the initial ARX code.
The code does suffer from the usual ARX requirement of having to be
recompiled for various platforsm which I was kind of hoping to avoid as was
trying to move away from ARX.
Sending some kind of command would probably be more flexible - that's a
fight for another day...
#pragma once
using namespace System;
using namespace System::Runtime::InteropServices;
extern void invokeTextStyleDialog(AcDbDatabase *AcadDatabase, CString
*StyleName);
#pragma unmanaged
void UnmanagedInvokeTextStyleDialog()
{
AcDbDatabase *db = curDoc()->database();
AcDbObjectId Id = curDoc()->database()->textstyle();
AcDbObjectPointer textstyleRec(Id,AcDb::kForRead);
ACHAR *pName;
textstyleRec->getName(pName);
CString s;
s.Format(_T("%s"),pName);
invokeTextStyleDialog(db, &s);
}
#pragma managed
namespace TextStyleDialog
{
public ref class Commands
{
public:
[Autodesk::AutoCAD::Runtime::CommandMethod("STD")]
static void ShowDialog()
{
UnmanagedInvokeTextStyleDialog();
}
};
}
Regards,
Adam
"Adam Davis"
wrote in message
news:6219746@discussion.autodesk.com...
Hi Tony,
Fair comment.
I have never got on that well with using the command line from .NET.
Especially as I already have a dialog open when I want to do this -
synchronicity just seems beyond me in some situations.
Cheers
Adam
"Tony Tanzillo" wrote in message
news:6219562@discussion.autodesk.com...
Why not just run the STYLE command via the command line ?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
"Adam Davis" wrote in message
news:6219084@discussion.autodesk.com...
Just to update,
Seems that the TextStyle String parameter is an MFC CString. .Net cannot
marshal a System.String to a CString via Pinvoke.
I tested the InvokeTextStyleDialog in ObjectArx and it worked fine so it is
not a problem with the actual function.
I haven't done it yet but it would appear that I just need to write a
wrapper class in managed C++ that takes a String and converts it to a
CString and then passes that to the InvokeTextStyleDialog.
Will let you know how I get on...
Adam
"Adam Davis" wrote in message
news:6218278@discussion.autodesk.com...
Hi All,
I am attempting to call the Text Sytle dialog from .NET. There is an
undocumented function in acad.exe that appears to be available. I can get
the dialog to appear but the dialog never actually initialises no matter
what string I send to the function.
I suspect there is a problem with the string conversion but can't seem to
get it to work.
Does anyone have any ideas?
{code}
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Namespace TextStyleDialogTest
Public Class Commands
Private Declare Auto Sub acedTextStyleDialog2006 Lib "acad.exe"
Alias
"?invokeTextStyleDialog@@YAXPAVAcDbDatabase@@PAV?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z"
(ByVal AcadDatabase As IntPtr, ByVal StyleName As String)
Private Declare Auto Sub acedTextStyleDialog2007 Lib "acad.exe"
Alias
"?invokeTextStyleDialog@@YAXPAVAcDbDatabase@@PAV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z"
(ByVal AcadDatabase As IntPtr, ByVal StyleName As String)
Public Sub ShowTextStyleDialog()
Dim db As Autodesk.AutoCAD.DatabaseServices.Database
db = Application.DocumentManager.MdiActiveDocument.Database
If
Autodesk.AutoCAD.ApplicationServices.Application.Version.Major > 16 Then
acedTextStyleDialog2007(db.UnmanagedObject, "Standard")
Else
acedTextStyleDialog2006(db.UnmanagedObject, "Standard")
End If
End Sub
End Class
End Namespace
{code}
Thanks in advance
Adam Davis