API: Need help to add custom property to Structural Members(SLDLFP-files)

Discussion in 'SolidWorks' started by Ronni, Mar 13, 2008.

  1. Ronni

    Ronni Guest

    Hey I have been trying to make a macro, so I can change the properties
    on all my weldment profiles.

    I have putted together some pieces but I cant find any info on how to
    treat the SLDLFP files, its no problem with the standards (drawings,
    parts and assemblies).

    So here is what I got so far.. I have putted some stars where I need
    input :)

    Dim swApp As SldWorks.SldWorks
    Dim swModel As *****
    Dim ReturnVal As Long
    Dim Response As String
    Dim DocName As String
    Dim Success As Boolean
    Dim DocType As String
    Dim swUpper As String
    Dim swDocTypeLong As Long
    Dim nErrors As Long
    Dim nWarnings As Long

    Const workDir = "x:\weldmentprofiles..."
    Const swDocType = ".SLDLFP"

    Set swApp = Application.SldWorks
    swApp.Visible = True
    ChDir (workDir)
    Response = Dir(workDir)
    Do Until Response = ""
    swUpper = UCase$(Response)
    If Right(swUpper, 7) = swDocType Then

    If UCase$(swDocType) = ".SLDPRT" Then
    swDocTypeLong = swDocPART
    ElseIf UCase$(swDocType) = ".SLDASM" Then
    swDocTypeLong = swDocASSEMBLY
    ElseIf UCase$(swDocType) = ".SLDDRW" Then
    swDocTypeLong = swDocDRAWING
    ElseIf UCase$(swDocType) = ".SLDLFP" Then
    swDocTypeLong = *****
    Else
    Stop 'Error Occured
    End If

    Dim swName As String
    swName = workDir & Response


    Set swModel = swApp.OpenDoc6(swName, *******,
    swOpenDocOptions_e.swOpenDocOptions_Silent, "", nErrors, nWarnings)

    retval = swModel.AddCustomInfo2("New prop name", "Text",
    "New prop text")

    Do events

    DocName = swModel.GetTitle
    ReturnVal = swModel.Save2(silent)

    swApp.CloseDoc DocName
    Set swModel = Nothing


    End If


    Response = Dir
    Loop


    Set swApp = Nothing
    End Sub
     
    Ronni, Mar 13, 2008
    #1
  2. Markku Lehtola, Mar 13, 2008
    #2
  3. Ronni

    Ronni Guest

    Thanks :)

    It worked along with removing the ( ) in AddCustomInfo2
     
    Ronni, Mar 13, 2008
    #3
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.