iLogic dim 2 csv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
This dim exp code is running into an error. trying to move all dims from inventor idw to csv
Error on Line 41 : 'kNoUnits' is not a member of 'Inventor.UnitsTypeEnum'.
Code :
Imports Inventor
Imports System.IO
Sub Main()
' Get the active part document
Dim oDoc As PartDocument
oDoc = TryCast(ThisApplication.ActiveDocument, PartDocument)
' Check if the active document is a part
If oDoc Is Nothing Then
MessageBox.Show("This rule is intended for use in a part document.")
Exit Sub
End If
' Define the file path for the CSV file
Dim csvFilePath As String = "C:\Temp\Dimensions.csv"
' Open or create the CSV file
Using sw As StreamWriter = New StreamWriter(csvFilePath)
' Write the header
sw.WriteLine("Dimension Name,Dimension Value")
' Find the sweep feature, regardless of name
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oSweep As SweepFeature = Nothing
' Iterate through all features to find the first sweep feature
For Each oFeature As PartFeature In oDef.Features
If TypeOf oFeature Is SweepFeature Then
oSweep = TryCast(oFeature, SweepFeature)
Exit For
End If
Next
If oSweep IsNot Nothing Then
' If the sweep feature is active, proceed
If Feature.IsActive(oSweep.Name) Then
' Loop through all parameters in the sweep feature's profile
For Each oParam As Parameter In oSweep.Profile.Parameters
' Check if the parameter represents a dimension
If oParam.UnitType = UnitsTypeEnum.kNoUnits Then
Dim dimName As String = oParam.Name
Dim dimValue As String = oParam.Value
' Write dimension name and value to the CSV file
sw.WriteLine(dimName & "," & dimValue)
End If
Next
Else
' Do something if the sweep feature is not active
End If
Else
MessageBox.Show("Sweep feature not found in the part.")
End If
End Using
' Inform the user
MessageBox.Show("Dimensions exported to CSV file at " & csvFilePath)
End Sub
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020