Sending values to an asset's key parameters with iLogic

Sending values to an asset's key parameters with iLogic

8013068
Enthusiast Enthusiast
1,837 Views
15 Replies
Message 1 of 16

Sending values to an asset's key parameters with iLogic

8013068
Enthusiast
Enthusiast

Hey, kind of a strange question, but...

Is there a way to modify the values of an asset's key parameters through iLogic? 

Here's the scenario:

I'm trying to make a factory layout template that can build layouts using information stored in an excel file. Right now, I am sending the parameters directly to components using commands like:

Parameter("asset:1", "keyparam") = value

This works great, unless there happens to be two or more instances of the same asset with different key parameters (ie 2 of the same ladder asset with different heights, etc) in which case any parameter changes affects all instances of that asset. You can change the same parameters manually with no problems though the "Factory Properties" Palette, but that kinda defeats the purpose of what I'm trying to do. I've noticed that as soon as one parameter is changed in the Palette, all the other parameters in that asset can be independently modified through iLogic with no problems, which is interesting. Is there any way to simply send values directly to the palette through iLogic? Or some other work around? 

Thanks in advance

0 Likes
Accepted solutions (1)
1,838 Views
15 Replies
Replies (15)
Message 2 of 16

olegd.prod
Autodesk
Autodesk
Accepted solution
Hello 8013068 (nice name btw :-),
You shouldn't be using iLogic to directly modify the instance file generated by Factory. When you do so, Factory metadata ends up out-of-sync with the contents of the files, which may lead to unexpected behavior later.

We added an API in our 2018.1 release that is designed to address the exact scenario you are talking about: driving a Factory layout based on data from some other system.
Take a look at the API docs: http://help.autodesk.com/view/FDU/2018/ENU/?guid=GUID-45CB93EA-B428-4D16-964A-3FA8EA4B2847

HTH

Oleg
0 Likes
Message 3 of 16

8013068
Enthusiast
Enthusiast

Thanks for your help!

0 Likes
Message 4 of 16

8013068
Enthusiast
Enthusiast

I've updated to 2018, and since I haven't made any plugins before, I went though the "my first inventor plugin" tutorial on the page you linked to. I've been struggling with it for a few days now, and I can't get the code on that page to work. It looks like it's written in a different programming language to me, but I don't know enough about  the API to fix it. Could you help? All I want to do is send a value to an asset's key parameter. Below is a screenshot showing the issues when I try to use that code.

 

Capture.PNG

0 Likes
Message 5 of 16

olegd.prod
Autodesk
Autodesk
You pasted C# code into a VB.NET project. You have 2 options:
1. Start a C# project for your add-in, or
2. Change the code you pasted in to use VB.NET syntax

Oleg
0 Likes
Message 6 of 16

8013068
Enthusiast
Enthusiast

Thanks for the quick reply. I know that's the issue, and have tried both options. Unfortunately, I'm just not familiar enough with either to get this to work, since I haven't done this before. The problems seem to start with the "getassetinstances" part. It claims that it is not a member of the API


C# attemptC# attemptVB.NET attemptVB.NET attempt

0 Likes
Message 7 of 16

spascual
Collaborator
Collaborator
I have been reading that code can be executed into ilogic... I say toi the result. Thanks,
0 Likes
Message 8 of 16

spascual
Collaborator
Collaborator

Accesing Assets API

 

SyntaxEditor Code Snippet

AddReference "Autodesk.Factory.PublicAPI.dll"
Imports Inventor
Imports Autodesk.Factory.PublicAPI
Imports Autodesk.Factory.PublicAPI.Currency

SyntaxEditor Code Snippet

Dim doc = ThisDoc.Document
insts = API.Instance.GetAssetInstancesFromLayout(doc)
MessageBox.Show(insts.Length.ToString(), "Get - COUNT")

 Geat ¡¡¡

0 Likes
Message 9 of 16

spascual
Collaborator
Collaborator

Hi,

I have sent to the post code to acces assets in FDS, Name and ID, but I'm unable to acces to Parameters via iLogic.

Any idea wellcome.

Thanks,

0 Likes
Message 10 of 16

olegd.prod
Autodesk
Autodesk
Hi there,
I am guessing that you are getting an error here: "MessageBox.Show(insts.Length.ToString(), "Get - COUNT")"
Is that correct?

The instance object has a Parameters property. This property is a Dictionary with parameter names and values.
See the docs for more info: https://help.autodesk.com/view/FDU/2018/ENU/?guid=GUID-45CB93EA-B428-4D16-964A-3FA8EA4B2847

Oleg
0 Likes
Message 11 of 16

spascual
Collaborator
Collaborator

This is running well with iLogic

I'm not getting errors.

I would like to acces Floor parameter in assets. Ilogic.

First get vaule and then modify it.

The code you say is for .net

Thanks,

 

 

SyntaxEditor Code Snippet

Dim oDoc = ThisDoc.Document
insts = API.Instance.GetAssetInstancesFromLayout(oDoc)

For Each Item In insts
	
	' xOffset = occ.Transformation.Translation.X * 10
	' yOffset = occ.Transformation.Translation.Y * 10
	'zOffset = Item.Transformation.Translation.Z * 10
	'zName = Item.Name
	MessageBox.Show(Item.InstanceName & " - " & Item.InstanceID, "Update Done")
Next

MessageBox.Show(insts.Length.ToString(), "Get - COUNT")

 

0 Likes
Message 12 of 16

olegd.prod
Autodesk
Autodesk
First of all - sorry, I was confused in my earlier message.
Current API doesn't support floor information
0 Likes
Message 13 of 16

spascual
Collaborator
Collaborator

Sorry Oleg,

Maybe I'm not explaining myself well... I would like to acces to some key parameter in an asset. For example "Angle" and get or update the value.

According your url link, it is posible with .NET, but I cannot find the correct syntaxis for iLogic.

Thanks,

0 Likes
Message 14 of 16

olegd.prod
Autodesk
Autodesk
C# syntax is: instance.Parameters["Angle"]

iLogic is basically VB.NET
As best as I can tell, VB.NET syntax would be instance.Parameters("Angle")
0 Likes
Message 15 of 16

spascual
Collaborator
Collaborator

Install last factory utilities update 2018.1

This runs with iLogic

 

AddReference "Autodesk.Factory.PublicAPI.dll"
Imports Inventor
Imports Autodesk.Factory.PublicAPI
Imports Autodesk.Factory.PublicAPI.Currency
Imports Autodesk.Factory.PublicAPI.Objects.v2
Imports Autodesk.Factory.PublicAPI.API.Instance
Imports System.Windows.Forms
Imports System
Imports System.Type
Imports System.Activator
Imports System.Runtime.InteropServices


Dim oDoc = ThisDoc.Document

oInsts = API.Instance.GetAssetInstances(oDoc)
'MessageBox.Show(oInsts.Length.ToString(), "Get - COUNT")

For Each Item In oInsts
    position = Item.Position
    position.OffsetX = 0
    Item.Position = position
    Item.Parameters("Angul") = 25    
    'MessageBox.Show(Item.ToString, "Get - COUNT")
Next

    oInsts = API.Instance.UpdateAssetInstances(oDoc, oInsts)
    MessageBox.Show("update position done")

Message 16 of 16

matthew_neesley
Collaborator
Collaborator

YES! YES!  Exactly what I needed! 😁

0 Likes