Autodesk Factory Design Suite
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to Place Assets with VB.NET?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi guys,
I've created a new asset browser for FDS Inventor 2013 in Visual Studio 2010 which shows a lot more information about the Asset (Machine) then the Standard Asset Browser does. That all went well, but now I'm having a problem when I select a Asset from this browser and want to place it in the drawing.
Here is my code for placing the asset:
Public Sub InsertAsset(ByVal AssetFile As String)
Dim doc As Inventor.Document
doc = m_inventorApplication.ActiveDocument
doc.Activate()
Dim CommandMgr As Inventor.CommandManager = m_inventorApplication.CommandManager
CommandMgr.PostPrivateEvent(PrivateEventTypeEnum.k FileNameEvent, AssetFile)
Dim ControlDef As Inventor.ControlDefinition
ControlDef = CommandMgr.ControlDefinitions.Item("Factory.Layout .PlaceAsset")
ControlDef.Execute()
End Sub
For some reason the command "Factory.Layout.PlaceAsset" does not accept the PostPrivateEvent of the CommandManager, so when I execute this code I get a FileDialog to choose which Model I want to insert in the drawing instead of accepting the filename in the PostPrivateEvent.
By the way: the variable AssetFile contains the FULL filename of the asset (i.e. c:\test\test\test.iam)
Does anybody know a good way to insert an asset from VB.NET?
Thanks alot!
Re: How to Place Assets with VB.NET?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi there -
This command doesn't work off a file name for its private event data. Instead, it looks for an XML string that contains information about the asset to be placed.
I would have to characterize the invocation of this command as "not supported," since it was never intended that external code would utilize it. That said, if you set things up properly, it should work -- though we may decide to change the details of the mechanism at some point in the future.
Please send me private e-mail if you'd like more details about what this XML data must look like.
Thanks,
Jeff DOT Pek AT Autodesk DOT com
Re: How to Place Assets with VB.NET?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
is there any FDS-API reference (official or not) available for the .NET interface?
I would like to change the parameters of placed assets in Inventor. Is there any possibility?
Regards
Re: How to Place Assets with VB.NET?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
No answer?
I had a lok at the program file in the directory 'C:\Program Files\Autodesk\Inventor 2013\Bin\InventorFactory'.
I could find some useful methods but not the one I was searching for?
@jparts:
Which reference did you use for the PlaceAsset method?
Re: How to Place Assets with VB.NET?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi andreas, Sorry for my very very very late reply. I haven't been on this forum for quiet some time now...
This is the code I'm using to place an asset:
Dim doc As Inventor.Document
doc = m_inventorApplication.ActiveDocument
doc.Activate()
Dim strAssetXml AsStringDim FamID AsString= Chr(34) & familyID & Chr(34)
Dim VarID AsString= Chr(34) & variantID & Chr(34)
Dim VarIsDefault AsString= Chr(34) & variantIsDefault & Chr(34)
If variantID <> ""Then
strAssetXml =
"<?xml version=""1.0"" encoding=""UTF-16""?>"_
&
"<CB_Action_Data>"_
&
"<CB_LIB_FILE_HANDLE VAL=" & FamID & "/>"_
&
"<CB_Action_Type VAL=""1""/>"_
&
"<CB_IS_IASSET VAL=""1""/>"_
&
"<CB_VARIANT_ID VAL=" & VarID & "/>"_
&
"<CB_IS_DEFAULT VAL=" & VarIsDefault & "/>"_
&
"</CB_Action_Data>"Else
strAssetXml =
"<?xml version=""1.0"" encoding=""UTF-16""?>"_
&
"<CB_Action_Data>"_
&
"<CB_LIB_FILE_HANDLE VAL=" & FamID & "/>"_
&
"<CB_Action_Type VAL=""1""/>"_
&
"<CB_IS_IASSET VAL=""0""/>"_
&
"</CB_Action_Data>"EndIfDim CommandMgr As Inventor.CommandManager= m_inventorApplication.CommandManager
CommandMgr.PostPrivateEvent(
PrivateEventTypeEnum.kStringEvent, strAssetXml)
Dim ControlDef As Inventor.ControlDefinition
ControlDef = CommandMgr.ControlDefinitions.Item(
"Factory.Layout.PlaceAsset")
ControlDef.Execute()
Hope this helps you. Variables are read from the xml files that come with the asset
Best regards!

