Thursday, March 27, 2008

Version Control

Hello,

Probably you will need or already need some version controlling on your software or on its modules.
This is made through the VS_VERSION_INFO resource inside C++ projects and through AssemblyInfo.cs file inside C# projects.

I have found an old but up to date tool (runs from VS2002 to VS2008) which allows you to easily manage these version informations. This tool, from Julijan Sribar, is an AddIn which tracks all opened projects and allow you to manage each version information. This tool is provided for free and its source code is also available for download: Versioning Controlled Build

Another issue is how to get this information at runtime to display, for instance, this version at an "About" like dialog inside your product. To do that in VC++ we need to read the VS_VERSION_INFO resource and get what we want. There is also another great article Retrieving version information from your local application's resource, from luetz,explaining how to do that.

Through C# there is no big deal, you can read the version information from AssemblyInfo as follows:

System.Reflection.Assembly oAssembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.FileVersionInfo oFileVersionInfo = FileVersionInfo.GetVersionInfo(oAssembly.Location) ;
MessageBox.Show("Version Info", oFileVersionInfo.ProductVersion);

Hope this help you to keep your file versions organized and updated!
Cheers!

8 comments :

Spencer said...

Hi,Fernando,Thank you very much! Your articles teached me a lot. Can you just help me one question whitch torchured me very much: I have a customed entity, if the user input the "OFFSET" command, I'd like to use my own offset instead of the native one, using "commandWillStart" of AcEditorReactor, I can know wheather he input "OFFSET" or not , but how can I prevent it, or block it when the user use offset command on my entity, and leave it alone while other entities? And how can I apply my own offset function? The customed entity is not derived from AcDbCurve, so overriding getOffsetCurves().... will not work, I tried it many times. Can you give me some advise, or just a simple sample? Thank you very very much!!!

Fernando Malard said...

Hi Spencer,

Maybe the most straight forward method would be redefine the native OFFSET command and implement yours.

The idea is to reproduce the OFFSET command flow and before apply the modification you can test if the entity is one of those you are interested or not.

If it is, use your own function if not, check if it is derived from AcDbCurve and call getOffsetCurves() by yourself.

I think this is simple and it will work. Of course this requires that your ARX is up and running inside the target computer.

Best regards,

Spencer said...

Thanks for your reply! But can you give me more information about how to "redefine the native OFFSET command "? I searched your articles and failed to find any stuff. And any sample? Thank you very much again!

Fernando Malard said...

Hi Spencer,

You can do that using UNDEFINE command. Inside your acrxEntryPoint() callback for kLoadDwgMsg message, add this:

ads_queueexpr( "(command \"_.undefine\" \"offset\")");

The ads_queueexpr() is an undocumented function which sends a command but through a queue avoiding document state problems.

Remember that even undefining a native command it will be still available from its DOT version ".offset".

Have you reconsidered deriving from AcDbCurve? I think this would be the most secure way to go and you will not need to handle each way the user can interact with OFFSET command.

Regards,

Fernando Malard said...

BTW, don`t forget the _T() macro:

ads_queueexpr(_T("(command \"_.undefine\" \"offset\")"));

Spencer said...

I'll try, hope it'll work. Thank you for your kind help!!! Thank you very much!!!

Spencer said...

Hi, Fernando,sorry to bother you again!

I have a pile of lines and arcs(I don't know the sequence), which can be joined into a valid lwpolyline, I use code as this:

rc=ads_command(RTSTR,_T(".pedit"),RTSTR, _T("M"),RTPICKS,ssname,RTSTR,_T(""),
RTSTR,_T("y"),RTSTR,_T("j"),RTSTR,_T(""),
//RTSTR,_T("w"),RTREAL,thickwid,
RTSTR,"",RTNONE);

but it doesn't work sometimes,(maybe when there's some entity opened for write already)

so, my question is: Do you know why the "pedit"command failed? Can I use arx code to join these lines and arcs into a whole polyline( I don't know their sequence)?How?Any example?
Thank you in advance!

Fernando Malard said...

Hi Spencer,

There is no native way to reproduce PEDIT command.

I would recommend you to test your command into a simple command which only ask the user to select the entities and then apply the command.

If the command is failing there must be something wrong with entities states (as you said) or maybe they are not connected curves.

Sorry about that.
Regards,