Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: Ho can i addin for microstaiotn v81

$
0
0

As Jan pointed out you have your AddinAttribute as

[AddIn(MdlTaskID = "AssemblyMgr", KeyinTree = "AssemblyDataManager.Commands.xml")]

and your file name is

Commands.XML

Rename your Commands.XML file to Commands.xml.

Also as pointed out by Jan although the V8i SDK is not required, there is an added benefit to using the SDK. You can validate the Command.xml  For example, using your code with only modified project settings and using

$(MSV8ISDKShortPath)mdl\bin\UstnXOM.exe ValidateAddIn "$(TargetPath)"

as part of the Post-Build event, you would have received the following error during build...

1>------ Build started: Project: AssemblyDataManager, Configuration: Debug x86 ------
1>  AssemblyDataManager -> F:\Program Files (x86)\Bentley\MicroStation V8i (SELECTseries)\MicroStation\mdlapps\AssemblyDataManager.dll
1> 
1>  Validating ASSEMBLYMGR AddIn: AssemblyDataManager.AssemblyDataManager
1>  The command table file or resource named AssemblyDataManager.Commands.xml could not be found for AddIn AssemblyDataManager.AssemblyDataManager
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: The command "Set MS=F:\PROGRA~3\Bentley\MICROS~1\MICROS~1\
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: Set MS_APPCONFIG=ustation.exe.config
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: F:\PROGRA~3\Bentley\MICROS~1\MICROS~1\mdl\bin\UstnXOM.exe ValidateAddIn "F:\Program Files (x86)\Bentley\MicroStation V8i (SELECTseries)\MicroStation\mdlapps\AssemblyDataManager.dll"
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073:     " exited with code 134217728.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== of the Post-Build event you would get the following build result

I reworked the Commands.xml file to the following...

<?xmlversion="1.0"encoding="utf-8" ?>

<KeyinTreexmlns="www.bentley.com/.../KeyinTree.xsd">

<!--Define the root keywords for the addin's commands-->

<RootKeyinTableID="root">

<KeywordSubtableRef="AssemblyDataManager"

CommandClass="MacroCommand"CommandWord="AssemblyDataManager">

<OptionsRequired="true"/>

</Keyword>

</RootKeyinTable>

<!--Define subtables-->

<SubKeyinTables>

<KeyinTableID="AssemblyDataManager">

<KeywordCommandWord="Open"></Keyword>

<KeywordSubtableRef="ItemActions"CommandClass="MacroCommand"CommandWord="ITEM">

<OptionsRequired="true"/>

</Keyword>

<KeywordSubtableRef="AssemblyActions"CommandClass="MacroCommand"CommandWord="ASSEMBLY">

<OptionsRequired="true"/>

</Keyword>

</KeyinTable>

<KeyinTableID="ItemActions">

<!--<Keyword CommandWord="degreesymbolfix"></Keyword>-->

<KeywordCommandWord="ATTACH"></Keyword>

<KeywordCommandWord="EDIT"></Keyword>

</KeyinTable>

<KeyinTableID="AssemblyActions">

<KeywordCommandWord="ATTACH"></Keyword>

<KeywordCommandWord="EDIT"></Keyword>

<KeywordCommandWord="REMOVE"></Keyword>

</KeyinTable>

</SubKeyinTables>

<!--Define a mapping from key-in to the method that handles the key-in.-->

<KeyinHandlers>

<KeyinHandlerKeyin="AssemblyDataManager ITEM ATTACH"

Function="AssemblyDataManager.KeyinCommands.ItemAttach"/>

<KeyinHandlerKeyin="AssemblyDataManager ITEM EDIT"

Function="AssemblyDataManager.KeyinCommands.ItemEdit"/>

<KeyinHandlerKeyin="AssemblyDataManager ASSEMBLY ATTACH"

Function="AssemblyDataManager.KeyinCommands.AssemblyAttach"/>

<KeyinHandlerKeyin="AssemblyDataManager ASSEMBLY EDIT"

Function="AssemblyDataManager.KeyinCommands.AssemblyEdit"/>

<KeyinHandlerKeyin="AssemblyDataManager ASSEMBLY REMOVE"

Function="AssemblyDataManager.KeyinCommands.AssemblyRemove"/>

</KeyinHandlers>

</KeyinTree>


However, in your project you did not have KeyinHandlers mapped to a static method in a .cs file. In this case, you would get the following errors - if you used the SDK using a similar Post Build as defined above.

1>------ Build started: Project: AssemblyDataManager, Configuration: Debug x86 ------

1> AssemblyDataManager -> F:\Program Files (x86)\Bentley\MicroStation V8i (SELECTseries)\MicroStation\mdlapps\AssemblyDataManager.dll1>

1> Validating ASSEMBLYMGR AddIn: AssemblyDataManager.AssemblyDataManager

1> AssemblyDataManager.Commands.xml is well-formed and schema valid against KeyinTree.xsd

1> static method AssemblyDataManager.KeyinCommands.ItemAttach not found for keyin "AssemblyDataManager ITEM ATTACH"

1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: The command "Set MS=F:\PROGRA~3\Bentley\MICROS~1\MICROS~1\

1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: Set MS_APPCONFIG=ustation.exe.config

1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: F:\PROGRA~3\Bentley\MICROS~1\MICROS~1\mdl\bin\UstnXOM.exe ValidateAddIn "F:\Program Files (x86)\Bentley\MicroStation V8i (SELECTseries)\MicroStation\mdlapps\AssemblyDataManager.dll"

1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: " exited with code 134217728.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If you did not use the SDK as shown, but the Command.xml is well-formed as noted in the above error, but is not mapped correctly you receive an exception similar to the following...


I can map the items in the Commands.xml to methods in a class as shown...

namespace AssemblyDataManager

{

///<summary>

/// Class used for running key-ins. The key-ins XML file commands.xml

/// provides the class name and the method names.

///</summary>

internalclassKeyinCommands

{

publicstaticvoid ItemAttach(string unparsed)

{

//insert code here

}

publicstaticvoid ItemEdit(string unparsed)

{

//insert code here

}

publicstaticvoid AssemblyAttach(string unparsed)

{

//insert code here

}

publicstaticvoid AssemblyEdit(string unparsed)

{

//insert code here

}

publicstaticvoid AssemblyRemove(string unparsed)

{

//insert code here

}

}

}

And now rebuilding with the SDK you should get the following...

1>------ Rebuild All started: Project: AssemblyDataManager, Configuration: Debug x86 ------
1>  AssemblyDataManager -> F:\Program Files (x86)\Bentley\MicroStation V8i (SELECTseries)\MicroStation\mdlapps\AssemblyDataManager.dll
1> 
1>  Validating ASSEMBLYMGR AddIn: AssemblyDataManager.AssemblyDataManager
1>  AssemblyDataManager.Commands.xml is well-formed and schema valid against KeyinTree.xsd
1> 
1>  No errors identified. The AddIn assembly AssemblyDataManager.dll appears to be valid.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

HTH


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>