Factory Design Utilities Forum
Welcome to Autodesk’s Factory Design Utilities Forums. Share your knowledge, ask questions, and explore popular Factory Design Utilities topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Place Assets with VB.NET?

10 REPLIES 10
Reply
Message 1 of 11
jparts
1133 Views, 10 Replies

How to Place Assets with VB.NET?

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!

 

 

10 REPLIES 10
Message 2 of 11
jeff.pek
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

Message 3 of 11
AnJanson
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

Message 4 of 11
AnJanson
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?

 

Message 5 of 11
jparts
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!

Message 6 of 11
paul.aurich9APA6
in reply to: jparts

Hi,

 

is there now a better/easier way to place assets?

 

I want to develop an application (.exe or something similar) that places assets and set up parameters like lenght, width, etc.

 

Is that possible?

 

Best regards

Message 7 of 11

Hi Paul,
There is no formal Factory API available today, so assets can't be placed programmatically.
We've heard this request a few times, and are thinking about it. Can you describe your scenario? How would your code figure out the values for length/width/etc?

Thank you,

Oleg
Message 8 of 11
GVDB
in reply to: olegd.prod

Hi Oleg,

 

i'm writing an addin for our Sales Department which uses Factory Design 2017.

It’s a pitty that there is no API for Factory Design (even not in 2018 release)

 

What I need is the following:

We have assets with a custom Key-parameter “HS-SS_Lossection”.

When we insert this asset in a factory layout and change this custom key-parameter by hand in Factory Properties and click on the Update button,

Factory Design creates a variant of the asset and replaces the inserted one.

 

What I need is, to do this by the addin. (VB.NET or C#) because the values of the key-parameters comes from our ERP-system.

 

Is it somehow possible to get access of this Factory property / key-parameter and update asset method,

to create a new variant when we change this property by code?

 

Kind Regards,

 

Geert

Message 9 of 11
olegd.prod
in reply to: GVDB

Hi Geert,
Unfortunately there is no API access to any of this today. We are definitely aware that this is an area for improvement for us, and plan to evaluating API access in a future release.

Thank you,

Oleg
Message 10 of 11
i.cattabiani
in reply to: jeff.pek

Moving the code to Inventor 2021 from Inventor 2018 makes Inventor crashes.
Something changed in the xml I think, because if I do not post it the command execute properly asking what I want to place.

@jeff.pek @olegd.prod, could you please help me?
@jpartsdo you already update to Inv 2021?

Message 11 of 11
CattabianiI
in reply to: jparts

I came up with this and it works now:

        ' load the asset without configuration
        Const assetDescriptorSimple As String = _
		"<?xml version=""1.0"" encoding=""UTF-16""?>" & 
		"<CB_Action_Data>"&
		"<CB_LIB_FILE_HANDLE VAL=""{0}""/>" & 
		"<CB_Action_Type VAL=""1""/>" & 
' removed: "<CB_IS_IASSET VAL=""0""/>" &
' added "<CB_IS_ASSET_CHAIN VAL=""0""/> " &
' added "<CB_IS_VARIANT_ASSET VAL = ""0""/> " & "</CB_Action_Data>"

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report