Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
philip1009
in reply to: MechMachineMan

There is a code sample that's supposed to get the value Part Number:

 

SyntaxEditor Code Snippet

Public Sub GetPropertySample()
    ' Get the active document.
    Dim invDoc As Document
    Set invDoc = ThisApplication.ActiveDocument
    
    ' Get the design tracking property set.
    Dim invDesignInfo As PropertySet
    Set invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
    
    ' Get the part number property.
    Dim invPartNumberProperty As Property
    Set invPartNumberProperty = invDesignInfo.Item("Part Number")
    
    MsgBox "Part Number: " & invPartNumberProperty.Value
End Sub

 

I tried to put it in my code below:

 

SyntaxEditor Code Snippet

Dim oDoc As PartDocument
oDoc=ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef=oDoc.ComponentDefinition
Dim oDataIO As DataIO
oDataIO=oDoc.ComponentDefinition.DataIO
If oCompDef.HasFlatPattern=False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim sOut As String
sOut="FLAT PATTERN DWG?AcadVersion=2000" _
+"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _
+"&SimplifySplines=True" _
+"&LINEAR TOLERANCE=0.010" _
+"&MergeProfilesIntoPolyline=True" _
+"&RebaseGeometry=False" _
+"&TrimCenterlines=True"
Dim invDesignInfo As PropertySet
invDesignInfo=oDoc.PropertySets.Item("Design Tracking Properties")
Dim invPartNumberProperty As Property
invPartNumberProperty=invDesignInfo.Item("Part Number")
Dim sFname As String
sFname=invPartNumberProperty & ".dwg"
oCompDef.DataIO.WriteDataToFile(sOut,sFname)

But I get an error on Line 22 (Dim invPartNumberProperty As Property) that says:

 

Keyword does not name a type.

 

I am lost on what this means.  I also noticed that when I type in "Property" it turns red and begins an outline ticker, is that what's causing the Keyword error?  Am I supposed to close this with a "End Property" line or something.  It honestly should not be this difficult to get the Part Number into an object or string so I can use it as the file name when I export the dwg.