Autodesk Factory Design Suite General Discussion

Autodesk Factory Design Suite General Discussion

Reply
Active Member
jparts
Posts: 10
Registered: ‎11-14-2011
Message 1 of 5 (330 Views)

How to Place Assets with VB.NET?

330 Views, 4 Replies
07-31-2012 01:44 AM

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.kFileNameEvent, 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!

 

 

Employee
jeff.pek
Posts: 329
Registered: ‎07-29-2008
Message 2 of 5 (326 Views)

Re: How to Place Assets with VB.NET?

07-31-2012 04:51 AM in reply to: jparts

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

Active Member
AnJanson
Posts: 7
Registered: ‎10-27-2007
Message 3 of 5 (244 Views)

Re: How to Place Assets with VB.NET?

09-14-2012 01:38 AM in reply to: jparts

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

Active Member
AnJanson
Posts: 7
Registered: ‎10-27-2007
Message 4 of 5 (224 Views)

Re: How to Place Assets with VB.NET?

09-17-2012 05:00 AM in reply to: AnJanson

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?

 

Active Member
jparts
Posts: 10
Registered: ‎11-14-2011
Message 5 of 5 (154 Views)

Re: How to Place Assets with VB.NET?

04-05-2013 04:08 AM in reply to: jparts

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!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.