
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone .
I want to write a txt/nc file with vba editor using a part i have already set parameters through i logic.My problem is how can i declare the features so if a feature is suppressed not to write its cordinates.
i also send you the code i am using
Option Explicit
Public Sub ModelParameters()
' Obtain the active document, this assumes
' that a part document is active in Inventor.
Dim oPartDoc As Inventor.PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Obtain the Parameters collection
Dim oParams As Parameters
Set oParams = oPartDoc.ComponentDefinition.Parameters
Dim oFeatures As PartFeatures
Set oFeatures = oPartDoc.ComponentDefinition.Features
' Obtain the Model Parameters collection
Dim oModelParams As ModelParameters
Set oModelParams = oParams.ModelParameters
Dim oUserParams As UserParameters
Set oUserParams = oParams.UserParameters
Dim oFeature As PartFeature
Set oFeature = oFeatures.RectangularPatternFeatures
Open "C:\Users\tso\Desktop\test.txt" For Output As #1 'Open file for output
' Program name
Print #1, ";NAME NONAME"
' Dimensions (Length, Width)
Print #1, ";DIM"; oUserParams.Item("Length").Value * 10; oUserParams.Item("Width").Value * 10; "1.5"
' Clamps potition
Print #1, ";PINZE "; "X"; oUserParams.Item("Left_clamp").Value * 10; "Y"; oUserParams.Item("Rigth_clamp").Value * 10
'Tool on the multi-tool and Offset
Print #1, ";TOOL 4000 TONDO 4 MTE6"
Print #1, ";OFFSET X"; oUserParams.Item("Offset_tool_4").Value * 10; "Y0 INDEX"
Print #1, ";CARICO XPIN Y780"
Print #1, ";LAVORAZIONE"
'Hole1
Print #1, ";COLPO X"; oUserParams.Item("Hole1x").Value * 10; "Y"; oUserParams.Item("Hole1y").Value * 10; "C-180"
Print #1, ";LAVORAZIONE"
'Hole2
Print #1, ";COLPO X"; oUserParams.Item("Hole2x").Value * 10; "Y"; oUserParams.Item("Hole2y").Value * 10; "C0"
Print #1, ";LAVORAZIONE"
Print #1, ";COLPO X"; oUserParams.Item("Hole3x").Value * 10; "Y"; oUserParams.Item("Hole3y").Value * 10; "C0"
Print #1, ";LAVORAZIONE"
Close #1 'Close file
End Sub
Solved! Go to Solution.