Community
No, you can't do that.
What properties are changed?
"C Witt" <cwitt_AT_trkeng.com> wrote in message
news:6107669@discussion.autodesk.com...
Is it possible to reference more than one version of these files in a single
project?
The reason I ask is that the 2 version of AutoCAD we are using have
different "properties" for the objects in question (the names change)...
Are you using Visual Studio 2008 ?
{code}
public static class VersionCompatibleExtensionMethods
{
public static ObjectId GetTextStyleId( this DBText instance )
{
if( textStyleProperty != null )
return (ObjectId) textStyleProperty.GetValue( instance, null );
else
throw new MissingMemberException();
}
public static ObjectId GetTextStyleId( this MText instance )
{
if( mtextStyleProperty != null )
return (ObjectId) mtextStyleProperty.GetValue( instance, null );
else
throw new MissingMemberException();
}
public static void SetTextStyleId( this DBText instance, ObjectId value )
{
if( textStyleProperty != null )
textStyleProperty.SetValue( instance, value, null );
else
throw new MissingMemberException();
}
public static void SetTextStyleId( this MText instance, ObjectId value )
{
if( mtextStyleProperty != null )
mtextStyleProperty.SetValue( instance, value, null );
else
throw new MissingMemberException();
}
static VersionCompatibleExtensionMethods()
{
textStyleProperty = typeof( DBText ).GetProperty( "TextStyle" );
if( textStyleProperty == null )
textStyleProperty = typeof( DBText ).GetProperty( "TextStyleId" );
mtextStyleProperty = typeof( DBText ).GetProperty( "TextStyle" );
if( mtextStyleProperty == null )
mtextStyleProperty = typeof( DBText ).GetProperty( "TextStyleId" );
}
private static PropertyInfo textStyleProperty = null;
private static PropertyInfo mtextStyleProperty = null;
}
{code}
The only option would be to use reflection.
The class below defines two extension methods for
DBText and MText that can be used in either release:
You use them just like they were methods of the
DBText and MText objects:
ObjectId GetTextStyleId();
void SetTextStyleId( ObjectId value );
[code]
<code>
{code}
public static class VersionCompatibleExtensionMethods
{
public static ObjectId GetTextStyleId( this DBText instance )
{
if( textStyleProperty != null )
return (ObjectId) textStyleProperty.GetValue( instance, null );
else
throw new MissingMemberException();
}
public static ObjectId GetTextStyleId( this MText instance )
{
if( mtextStyleProperty != null )
return (ObjectId) mtextStyleProperty.GetValue( instance, null );
else
throw new MissingMemberException();
}
public static void SetTextStyleId( this DBText instance, ObjectId value )
{
if( textStyleProperty != null )
textStyleProperty.SetValue( instance, value, null );
else
throw new MissingMemberException();
}
public static void SetTextStyleId( this MText instance, ObjectId value )
{
if( mtextStyleProperty != null )
mtextStyleProperty.SetValue( instance, value, null );
else
throw new MissingMemberException();
}
static VersionCompatibleExtensionMethods()
{
textStyleProperty = typeof( DBText ).GetProperty( "TextStyle" );
if( textStyleProperty == null )
textStyleProperty = typeof( DBText ).GetProperty( "TextStyleId" );
mtextStyleProperty = typeof( DBText ).GetProperty( "TextStyle" );
if( mtextStyleProperty == null )
mtextStyleProperty = typeof( DBText ).GetProperty( "TextStyleId" );
}
private static PropertyInfo textStyleProperty = null;
private static PropertyInfo mtextStyleProperty = null;
}
{code}
</code>
[/code]
{code}
public static class VersionCompatibleExtensionMethods
{
public static ObjectId GetTextStyleId( this DBText instance )
{
if( textStyleProperty != null )
return (ObjectId) textStyleProperty.GetValue( instance, null );
else
throw new MissingMemberException();
}
public static ObjectId GetTextStyleId( this MText instance )
{
if( mtextStyleProperty != null )
return (ObjectId) mtextStyleProperty.GetValue( instance, null );
else
throw new MissingMemberException();
}
public static void SetTextStyleId( this DBText instance, ObjectId value )
{
if( textStyleProperty != null )
textStyleProperty.SetValue( instance, value, null );
else
throw new MissingMemberException();
}
public static void SetTextStyleId( this MText instance, ObjectId value )
{
if( mtextStyleProperty != null )
mtextStyleProperty.SetValue( instance, value, null );
else
throw new MissingMemberException();
}
static VersionCompatibleExtensionMethods()
{
textStyleProperty = typeof( DBText ).GetProperty( "TextStyle" );
if( textStyleProperty == null )
textStyleProperty = typeof( DBText ).GetProperty( "TextStyleId" );
mtextStyleProperty = typeof( DBText ).GetProperty( "TextStyle" );
if( mtextStyleProperty == null )
mtextStyleProperty = typeof( DBText ).GetProperty( "TextStyleId" );
}
private static PropertyInfo textStyleProperty = null;
private static PropertyInfo mtextStyleProperty = null;
}
{code}
Hi. can you explain how to use you code in VS2010 express? (If i can.) I have many acad version 2009, 2010 and 2012
I dont know how to manage all this version... I want build only one DDL (if i can).
I dont know how to manage VS2010 exp for not check a part of my code.
My think :
Try
'v autocad 2010
DBTexte.TextStyleID =....
catch ex as exception
'v autocad 2009
DBTexte.TextStyle = ...
end try.
if a build with dll from autocad 2009 i have error for .TextStyleId and for autocad 2010 .textStyle
so ....
Thx
Can't find what you're looking for? Ask the community or share your knowledge.