×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Solidworks API read-only attribute

Solidworks API read-only attribute

Solidworks API read-only attribute

(OP)
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

RE: Solidworks API read-only attribute

' ******************************************************************************
' code by Tick
'http://www.EsoxRepublic.com
' ******************************************************************************
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

"Great ideas need landing gear as well as wings."--C. D. Jackson
http://www.EsoxRepublic.com

RE: Solidworks API read-only attribute

(OP)
Thanks heaps, I'll implement the code and post how it all went.

Steve

RE: Solidworks API read-only attribute

(OP)
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

RE: Solidworks API read-only attribute

Sorry.  Misunderstood.

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

"Great ideas need landing gear as well as wings."--C. D. Jackson
http://www.EsoxRepublic.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources