Friday Brain Fade and error checking loops

Friday Brain Fade and error checking loops

Anonymous
Not applicable
304 Views
2 Replies
Message 1 of 3

Friday Brain Fade and error checking loops

Anonymous
Not applicable
Hi guys

having a case of friday brain fade and i can't for the life of me figure out this problem.

Below is my code for creating the dxf from a flat pattern and it works just great. The issue is that on our title blocks we like to have a text box that lists the dxf filename path and revision. This also works great.... the first time. The problem i have is when i subsequently run the code ie rev 2 3 etc the dxf is created with the correct revision number but the custom text field isn't getting updated and i think it has something to do dwith the error loop check at the bottom end of the code. The error check is a simple way (or i thought so at the time) to stop the routine from crashing if the custom iproperty dxf_filename isn't already defined.
Look forward to any / all input on this.

thanks

daren

M90 84.29 4GB Win XPsp2 Inventor 2008Pro

Public Sub DXFOUT()

'Check for Sheetmetal File
If ThisApplication.ActiveDocument.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox "Unable to extract DXF file from this file. Only works for Sheet Metal File types."
End
End If

'Define Variables
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
Dim oPropSet As PropertySet
Dim oProp As Property

'Define DataIO
Dim oDataIO As DataIO
Set oDataIO = oDoc.ComponentDefinition.DataIO
Dim oOut As String
oOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=0&InteriorProfilesLayer=0"

'Collect iProperties to define file name
Set oPropSet = oPropSets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")
Dim oREVNumber As String
oREVNumber = oPropSet.ItemByPropId(kRevisionSummaryInformation).Value

Set oPropSet = oPropSets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")
Dim oPartNumber As String
oPartNumber = oPropSet.ItemByPropId(kPartNumberDesignTrackingProperties).Value

'Dim oFileNameLength As String
'oFileNameLength = Len(ThisApplication.ActiveDocument.DisplayName)

'Set dxf File Location
Dim oPathName As String
'oPathName = Left(oDoc.FullFileName, Len(oDoc.FullFileName) - oFileNameLength)
oPathName = "c:/punching files/"

'Set dxf File Name
Dim oDXFName As String
If oREVNumber < 10 Then
oDXFName = oPathName & oPartNumber & "B0" & oREVNumber & ".dxf"
Else
oDXFName = oPathName & oPartNumber & "B" & oREVNumber & ".dxf"
End If


'Write dxf File out
oDataIO.WriteDataToFile oOut, oDXFName

'Check for and define or set custom iproperty for use on title block
Dim oCustomPropset As PropertySet
Set oCustomPropset = oPropSets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

On Error Resume Next
Err.Clear
Check = oCustomPropset.Item(dxf_filename).Value

If Err.Number <> 0 Then
'Adding the new Property to the CustomPropertySet
Call oCustomPropset.Add(oDXFName, "dxf_filename")

Else

ThisApplication.ActiveDocument.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("dxf_filename").Value = oDXFName

Err.Clear

End If

On Error GoTo 0

End Sub
0 Likes
305 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Change the following line:

Check = oCustomPropset.Item(dxf_filename).Value

to

Check = oCustomPropset.Item("dxf_filename").Value

Sanjay-

wrote in message news:5627207@discussion.autodesk.com...
Hi guys

having a case of friday brain fade and i can't for the life of me figure out
this problem.

Below is my code for creating the dxf from a flat pattern and it works just
great. The issue is that on our title blocks we like to have a text box that
lists the dxf filename path and revision. This also works great.... the
first time. The problem i have is when i subsequently run the code ie rev 2
3 etc the dxf is created with the correct revision number but the custom
text field isn't getting updated and i think it has something to do dwith
the error loop check at the bottom end of the code. The error check is a
simple way (or i thought so at the time) to stop the routine from crashing
if the custom iproperty dxf_filename isn't already defined.
Look forward to any / all input on this.

thanks

daren

M90 84.29 4GB Win XPsp2 Inventor 2008Pro

Public Sub DXFOUT()

'Check for Sheetmetal File
If ThisApplication.ActiveDocument.SubType <>
"{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox "Unable to extract DXF file from this file. Only works for Sheet
Metal File types."
End
End If

'Define Variables
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
Dim oPropSet As PropertySet
Dim oProp As Property

'Define DataIO
Dim oDataIO As DataIO
Set oDataIO = oDoc.ComponentDefinition.DataIO
Dim oOut As String
oOut = "FLAT PATTERN
DXF?AcadVersion=2004&OuterProfileLayer=0&InteriorProfilesLayer=0"

'Collect iProperties to define file name
Set oPropSet = oPropSets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")
Dim oREVNumber As String
oREVNumber = oPropSet.ItemByPropId(kRevisionSummaryInformation).Value

Set oPropSet = oPropSets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")
Dim oPartNumber As String
oPartNumber =
oPropSet.ItemByPropId(kPartNumberDesignTrackingProperties).Value

'Dim oFileNameLength As String
'oFileNameLength = Len(ThisApplication.ActiveDocument.DisplayName)

'Set dxf File Location
Dim oPathName As String
'oPathName = Left(oDoc.FullFileName, Len(oDoc.FullFileName) -
oFileNameLength)
oPathName = "c:/punching files/"

'Set dxf File Name
Dim oDXFName As String
If oREVNumber < 10 Then
oDXFName = oPathName & oPartNumber & "B0" & oREVNumber & ".dxf"
Else
oDXFName = oPathName & oPartNumber & "B" & oREVNumber & ".dxf"
End If


'Write dxf File out
oDataIO.WriteDataToFile oOut, oDXFName

'Check for and define or set custom iproperty for use on title block
Dim oCustomPropset As PropertySet
Set oCustomPropset =
oPropSets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

On Error Resume Next
Err.Clear
Check = oCustomPropset.Item(dxf_filename).Value

If Err.Number <> 0 Then
'Adding the new Property to the CustomPropertySet
Call oCustomPropset.Add(oDXFName, "dxf_filename")

Else

ThisApplication.ActiveDocument.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("dxf_filename").Value
= oDXFName

Err.Clear

End If

On Error GoTo 0

End Sub
0 Likes
Message 3 of 3

Anonymous
Not applicable
Sanjay

Many thanks that has solved my problem. I think it was a case of not seeing the forest for the trees.

thanks

daren

M90 84.29 4GB Win XPsp2 Inventor 2008Pro
0 Likes