.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiple acdbmgd & acmgd references?

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
1203 Views, 14 Replies

Multiple acdbmgd & acmgd references?


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)...



--

Work: VISTA Ultimate x32 - AMD 64 X2
Dual Core 4200 2.2GHz, 4 Gigs Ram, GeForce
6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150

14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

No, you can't do that.

What properties are changed?

"C Witt" 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)...


--
Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce
8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2
Gigs Ram, Nvidia GeForce 6150
Message 3 of 15
Anonymous
in reply to: Anonymous


The textstyle property of the text object changed from "textstyle" to
"textstyleid"...



Work: VISTA
Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
color="#666666">GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

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)...




Message 4 of 15
Anonymous
in reply to: Anonymous

Are you using Visual Studio 2008 ?

--
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


"C Witt" wrote in message
news:6107734@discussion.autodesk.com...
The textstyle property of the text object changed from "textstyle" to
"textstyleid"...


Work: VISTA Ultimate x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs Ram,
GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce
8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2
Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
No, you can't do that.

What properties are changed?

"C Witt" 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)...
Message 5 of 15
Anonymous
in reply to: Anonymous


yes



Work: VISTA
Ultimate/Windows 7 x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs
Ram, GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

Are you using Visual Studio 2008 ?



Message 6 of 15
Anonymous
in reply to: Anonymous

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}

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]

--
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


"C Witt" wrote in message
news:6108204@discussion.autodesk.com...
yes


Work: VISTA Ultimate/Windows 7 x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs
Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce
8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2
Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
Are you using Visual Studio 2008 ?
Message 7 of 15
Anonymous
in reply to: Anonymous


Thank you Tony, I will give that a shot!



Work: VISTA
Ultimate/Windows 7 x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs
Ram, GeForce 6800GS 256MB


Home: VISTA Ultimate x64 - AMD 64 Quad
Core 2.2GHz, 8 Gigs Ram, GeForce 8600GT 512MB


Laptop (17" HP): VISTA Premium x32 -
color="#000000">AMD Turion X2 Dual Core TL-50 1.6GHz, 2 Gigs Ram,
color="#666666">Nvidia GeForce 6150





Tony Tanzillo wrote:

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]



Message 8 of 15
Anonymous
in reply to: Anonymous

C Witt wrote:

> The textstyle property of the text object changed from "textstyle" to
> "textstyleid"...

If you are using VB on VS2005 and need to support 2007 then this appears
to work.

If AcdApp.Version = 17.0 Then
CallByName(AddEnt, "TextStyle", CallType.Set, StyRec.ObjectId)
Else
CallByName(AddEnt, "TextStyleId", CallType.Set, StyRec.ObjectId)
End If

Terry
Message 9 of 15
Anonymous
in reply to: Anonymous

Rather than branching once when the code loads, your so-called
solution branches every single time the property's value is needed.

Astounding.

--
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


"Terry W. Dotson" wrote in message
news:6150151@discussion.autodesk.com...
C Witt wrote:

> The textstyle property of the text object changed from "textstyle" to
> "textstyleid"...

If you are using VB on VS2005 and need to support 2007 then this appears
to work.

If AcdApp.Version = 17.0 Then
CallByName(AddEnt, "TextStyle", CallType.Set, StyRec.ObjectId)
Else
CallByName(AddEnt, "TextStyleId", CallType.Set, StyRec.ObjectId)
End If

Terry
Message 10 of 15
Anonymous
in reply to: Anonymous

For those that use VS2005, you can still use the code posted
as extension methods, by just converting them to plain old
static methods (non-extension methods), and passing the
DBText or MText objects to them as the first parameter. Just
remove the 'this' from first parameter declaration.

--
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


"Tony Tanzillo" wrote in message
news:6108262@discussion.autodesk.com...
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}

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]

--
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


"C Witt" wrote in message
news:6108204@discussion.autodesk.com...
yes


Work: VISTA Ultimate/Windows 7 x32 - AMD 64 X2 Dual Core 4200 2.2GHz, 4 Gigs
Ram, GeForce 6800GS 256MB
Home: VISTA Ultimate x64 - AMD 64 Quad Core 2.2GHz, 8 Gigs Ram, GeForce
8600GT 512MB
Laptop (17" HP): VISTA Premium x32 - AMD Turion X2 Dual Core TL-50 1.6GHz, 2
Gigs Ram, Nvidia GeForce 6150


Tony Tanzillo wrote:
Are you using Visual Studio 2008 ?
Message 11 of 15
bert.vanpeteghem
in reply to: Anonymous

good thinking on using extension methods for version compatibility...

I've been using the #if conditional directive, and then build with different constants defined, according to versions... Works too, but I like this solution a lot more!

Time to review some of my code 🙂
Message 12 of 15
Anonymous
in reply to: Anonymous

Tony Tanzillo wrote:

> Rather than branching once when the code loads, your so-called
> solution branches every single time the property's value is needed.

The example was when I first discovered the alternative, and was not
intended to be optimized. I later changed it to preset the string
variable on loading to avoid the branches.

CallByName(AddEnt, StyPrp, CallType.Set, StyRec.ObjectId)

What is "astounding" is that it took you almost 24 hours to criticize.

Terry
Message 13 of 15
Anonymous
in reply to: Anonymous

>> What is "astounding" is that it took you almost 24 hours to criticize.

Nothing astounding about that, it's a side-effect of being busy.

{quote}

The example was when I first discovered the alternative, and was not
intended to be optimized. I later changed it to preset the string
variable on loading to avoid the branches.

{quote}

Duh.

It still isn't 'optimized'.

Perhaps if you better understood the API you're using, you might understand
why there is a difference between caching a property name in a string, and
caching the PropertyInfo object returned by the reflection search for the
name.

Unfortunately I have other things things to do and can't really afford to
take the time to tutor you in the finer points of using reflection or
late-binding overhead, but feel free to visit the Microsoft newsgroups and
ask them to tell you more about it.

--
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


"Terry W. Dotson" wrote in message
news:6150674@discussion.autodesk.com...
Tony Tanzillo wrote:
Message 14 of 15
Anonymous
in reply to: Anonymous

Tony Tanzillo wrote:

> ... can't really afford to take the time to tutor you ...

All well and good as I didn't ask for (or need) your help.

Terry
Message 15 of 15
AubelecBE
in reply to: Anonymous

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost