Hallo zusammen
Ich habe ein Problem damit UserParameter im PartDocument anzulegen
Folgendes habe ich breits hinbekommen ich greife auf zwei Benutzerproperties zu.
Und möchte dann drei UserParameter erstellen (G_W; G_H, B_L)
Aber ich bekomme bei der Zuweisung
Dim oParameters As Parameters
oParameters = oInvApp.ActiveDocument.componetenDefinition schon ein Problem denn ComponentenDefinition ist nicht vorhanden.
kann mir jemand von euch sagen was ich falsch machte?
Code:
Imports Inventor
Imports System.Activator
Imports System.Windows.Forms
Public Class Form1
Public oInvApp As Inventor.Application = Nothing
Dim oquitInventor As Boolean = False
Dim oDoc As Document
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oParameters As Parameters
oParameters = oInvApp.ActiveDocument.co
oInvApp.SilentOperation = True
Try
oInvApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
End Try
If oInvApp Is Nothing Then
Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")
oInvApp = CreateInstance(inventorAppType)
oquitInventor = True
End If
'gehe zum Dokument
oDoc = oInvApp.ActiveDocument
If oInvApp.Documents.Count = 0 Then
MsgBox("Kein Dokument geöffnet!")
Me.Close()
Exit Sub
End If
If oInvApp.Documents.Count > 0 Then
If oInvApp.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("Falsches Dokument: Es muß ein Teile oder Part-Dokument geöffnet sein!")
Me.Close()
Exit Sub
End If
End If
' Gehe zum benutzerdefinierte (custom) Propertie
Dim invCustomPropertySet As PropertySet
invCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
Dim oProp As [Property]
For Each oProp In invCustomPropertySet
If oProp.Name = "ROHMATERIAL" Then
Me.txtRohmat.Text = oProp.Value
ElseIf oProp.Name = "L1" Then
Me.txtL1.Text = oProp.Value
End If
Next
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP