Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VB.net Ilogic.Interfaces docAndParamName

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
j.romo
237 Views, 3 Replies

VB.net Ilogic.Interfaces docAndParamName

Ok I just ran out of ideas and been searching the forum for an example but just can get it

I want to run a Ilogic code in VB.net, currently I can run Jelte Ilogic AbstractRule abu cant get information or an example of how to get parameters in the class IparamDynamic seems the way to go but I just cant get the syntax correct_____   ReadOnly Property Param(docAndParamName As String) As Inventor.Parameter

docAndParamName: Parameter name (with optional document name prefix). ???? I have uses the parameter name and I get the error Something went Wrong while running the rule. Message: Object Reference not set to an instance of an object.

how do I get docAndParamName in a single string, the value of the Parameter is in the Main Assembly.

here is my abstract rule

Imports Autodesk.iLogic.Interfaces
Imports Autodesk.iLogic.Runtime
Imports Inventor

Public MustInherit Class AbstractRule

    Public Property ThisApplication As Inventor.Application
    Public ReadOnly Property ThisDoc As ICadDoc
        Get
            Return New CadDoc(ThisApplication.ActiveDocument)
        End Get
    End Property

    Public Property oParam As IParamDynamic

End Class

here is a sample code just to read a parameter in the assembly is running.

Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports System.IO
Public Class ThisRule
    Inherits AbstractRule


    Public Sub Main()


 ' Your iLogic code goes here.

        Dim servoStep As String = oParam.Value("d0")

        MsgBox(servoStep)


  
    
       'CURRENT ILOGIC RULE I WANT TO RUN FROM THIS SAMPLE ALL PARAMETERS ARE 
       'IN THE MAIN ASSEMBLY 
        'Dim oIncrement As Integer
        'oIncrement = 1 ul

        'PASOS += oIncrement
        'If SERVO_SAVE = 0 Then
        '    SERVO_STEP = PASO_SIDE * PASOS
        'Else  'SERVO_SAVE Mod PASO_SIDE = 0 Then
        '    SERVO_STEP = (PASO_SIDE * PASOS) + SERVO_SAVE
        '    '	Else
        '    '		i = MessageBox.Show("EL PASO DE SERVO DEBE SER DIVISIBLE ENTRE 1.9375", "REVISAR PASOS ANTERIORES", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)


        'End If
        'iLogicVb.UpdateWhenDone = True

    End Sub

End Class
3 REPLIES 3
Message 2 of 4
TechInventor20
in reply to: j.romo

I have no idea what you wan't to accomplish with that code, but here are some things that might help.

 

Get userparameter:

 

Dim asmDoc As Document
asmDoc = _invApp.ActiveDocument
Dim activeassembly$
activeassembly$ = asmDoc .FullFileName

Dim oUserParameters As UserParameters
oUserParameters = asmDoc .Parameters.UserParameters



oUserParameters.Item("Your parameter item").value = "the value you want"

or

Dim Str as string = oUserParameters.Item("Your parameter item").value

 

 

or you want to run a external rule from within vb.net in inventor.

 

Dim _invApp As Inventor.Application



'Run external Ilogic rule
Dim oDoc As Inventor.Document

Dim iLogicAddinId As String = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}"
Dim iLogicAddIn As Inventor.ApplicationAddIn = _invApp.ApplicationAddIns.ItemById(iLogicAddinId)
Dim iLogicAuto As Object = iLogicAddIn.Automation
If (iLogicAuto Is Nothing) Then Exit Sub

Dim RuleName As String = "L:\01 - Inventor\06 - VBA\I-logic regels\Undo.iLogicVb"

iLogicAuto.RunExternalRule(oDoc, RuleName)

Message 3 of 4
WCrihfield
in reply to: j.romo

Hi @j.romo.  If you are set on using iLogic's IParamDynamic Interface for accessing parameters, instead of the standard API route, I generally recommend avoiding using the 'docAndParamName' single input method, due to lack of documentation, and stick with using the two input method.  The first input Object for that version is fairly clear...through research & testing, not help documentation.  When accessing the parameters of a component in an assembly, this can simply be the ComponentOccurrence.Name.  But when accessing a referenced document, it needs to be the file name, without path, but with file extension.  And using Document.DisplayName is not always a stable way of providing that input, so I usually use the System.IO.Path.GetFileName(Document.FullFileName) method of attaining the proper input String.  I am still not sure why they specify this input as an Object, instead of a String directly, because I do not think I have ever seen a case where someone has sucessfully used a different Type of input there.  However, I do hot think this Interface has a way to deal with the new ModelStates properly...yet.  What I mean by that is, you can not specify which ModelState version of the 'target' document you want to access the parameter from/within.  It will work OK sometimes, because the right ModelState may already be the 'active' one in that document, which results in you actually working with the 'factory' version of the document, which is the only version you can edit.  Also that Interface is limited to only allowing you to access either the 'active' document, or a document that is referenced by the 'active' document.  It can not access what I call a 'parallel' document (a document that may be open, visibly or otherwise, but not referenced in any way to the 'active' document.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4
j.romo
in reply to: WCrihfield

You are right there is not much documentation for this method.

i started all over again in regular API VB.net

thank you for the insight.

 

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report