Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

101 views
Skip to first unread message

Ronni

unread,
Mar 13, 2008, 3:56:44 AM3/13/08
to
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

Markku Lehtola

unread,
Mar 13, 2008, 6:22:52 AM3/13/08
to
SLDLFP is treated as normal part (swDocPART). Here's my tool to add
attributes: http://www.markkulehtola.net/wb/pages/solidworks/swxx-tools/older-stuff/swab.php

Ronni

unread,
Mar 13, 2008, 8:20:55 AM3/13/08
to
Thanks :-)

It worked along with removing the ( ) in AddCustomInfo2

0 new messages