Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solidworks API read-only attribute

Status
Not open for further replies.

powder99

Mechanical
Joined
Jan 8, 2004
Messages
25
Location
CA
I am new to API programming and I was wondering if anyone can point me in the right direction. I need to write a small program that enables a solidworks user to set the 'read-only' attribute from within solidworks. At present we set this attribute in windows explorer under properties. I would like this to be an icon within a toolbar that pops up a small window with a check option for read-only.

Any help would be appreciated.

Steve
 
' ******************************************************************************
' code by Tick
'' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Dim retval As Variant
Dim ReadOnlyState As Boolean 'TRUE= only, FALSE = not

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
ReadOnlyState = Part.IsOpenedReadOnly()
If ReadOnlyState = False Then ReadOnlyState = True Else ReadOnlyState = False
boolstatus = Part.SetReadOnlyState(ReadOnlyState)

End Sub

[bat]"Great ideas need landing gear as well as wings."--C. D. Jackson [bat]
 
Thanks heaps, I'll implement the code and post how it all went.

Steve
 
Hi Tick,
I ran the code and the program works well, however it only temporarily sets the drawing to read-only whilst the file is open. What I was hoping for was to permanently set the attribute to 'read-only' in the properties window in Windows Explorer. Ideally I'm attempting to code a button that once clicked will first save the file and then change the read-only attribute.

Thanks again for your help
 
Sorry. Misunderstood.

You'll have to dig into Windows API for what you want, I think. Declare Function etc. etc.

[bat]"Great ideas need landing gear as well as wings."--C. D. Jackson [bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top