API - Access the User Specified Name

Discussion in 'SolidWorks' started by Wayne Tiffany, Jun 17, 2004.

  1. We have a fairly involved program here that allows the user to select a
    particular material from a cascading type of list structure and go all the
    way to a unique ASI part number. Then if in SW, the info such as part
    number, description, etc can be inserted into the currently open part. As
    it was written years ago, it puts that info into the custom properties area
    of the SW part, and at this time I want to change it so it puts it into
    config specific areas instead. I can get it to access the config specific
    properties, but can't seem to figure out how to get & write to the User
    Specified Name in the properties box under the Part number displayed when
    used in a bill of materials.

    I have pasted in my test code here so you can see what I have tried.
    Anybody see my error and can offer some assistance, please?

    Dim swApp As Object
    Dim Part As Object
    Dim boolstatus As Boolean
    Dim SwConfig As SldWorks.Configuration
    Dim ConfigName As String
    Dim AltName As Variant
    Dim ConfigDesc, ConfigLength As String

    Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc

    Set SwConfig = Part.GetActiveConfiguration
    ConfigName = Part.GetActiveConfiguration.Name

    boolstatus = True
    SwConfig.UseAlternateNameInBOM = boolstatus
    .....This next line is the bad line.
    AltName = Part.SwConfig.alternateName
    ConfigDesc = Part.CustomInfo2(ConfigName, "Description")
    ConfigLength = Part.CustomInfo2(ConfigName, "Length")

    End Sub


    WT
     
    Wayne Tiffany, Jun 17, 2004
    #1
  2. for some reason, you have to create the property first with
    Part.AddCustomInfo3 ( ConfigName, "Description", swCustomInfoText,
    FieldValue )

    then you can read/write it with CustomInfo2 the way you did.
     
    Philippe Guglielmetti, Jun 17, 2004
    #2
  3. I figured out my error to actually access the property (remove the Part from
    the line AltName = Part.SwConfig.alternateName) but now I can't get the
    UseAlternateNameInBOM to toggle on. If it's off in the part, then
    regardless of my setting in the code, it stays false. Here's my line:

    SwConfig.UseAlternateNameInBOM = True

    What am I missing?

    WT
     
    Wayne Tiffany, Jun 17, 2004
    #3
  4. Wouldn't this just add another custom property, rather than writing to the
    User Specified Name so it shows up in the BOM? Also, see my second post .
    Thanks.

    WT
     
    Wayne Tiffany, Jun 17, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.