vba change revision property

Experimenter
Experimenter

I have put together some code to execute in excel sheet.

Basically a place to enter revision letter and description fo the rev.

When the button is pressed to execute the macro in excel, it sorts the revisons by letter

and puts the latest revision up at the top and is view on the draft.

 

Our templates are setup  to pull the revision from the R1 associated file on the draft.

I have been able to use newell's code to automate the changing of the revison on the draft

but i want it to also change the revision level on the associated file(s) that are linked to

the draft with the same file name. (.par,psm,asm)

 

 

Option Explicit


Sub ModifyRevisionNumber(objPropertySets As SolidEdgeFramework.PropertySets)
    Dim objProperties As SolidEdgeFramework.Properties
    Dim objProperty As SolidEdgeFramework.Property
           
    ' Get reference to the ProjectInformation property set.
    Set objProperties = objPropertySets.Item("ProjectInformation")
    Set objProperty = objProperties.Item("Revision")
    objProperty.Value = Cells(3, 1).Value    
    
    Set objProperty = Nothing
    Set objProperties = Nothing
End Sub

 

Any help would be much appreciated.

Thanks

 

9 REPLIES

Re: vba change revision property

Valued Contributor
Valued Contributor

Access the modellink of your active draft.

 

using,

Dim objmodellinks As SolidEdgeDraft.ModelLinks
Dim objmodellink As SolidEdgeDraft.ModelLink

 

then open the part properties using,

 

Dim AobjPropSets As SolidEdgeFileProperties.PropertySets

 

objPropSets = CreateObject("SolidEdge.FileProperties")

 

next,

 

use objmodellink.filename ( .psm or .par or .asm)

 

apply your revision value to opened part property.

 

Note:

Make sure part file not opened in active screen. if part file opened, then code will consider it as "Read-only" file.

 

 

Re: vba change revision property

Experimenter
Experimenter

thanks for you reply

 

i am very new to working with vba and solid edge.

 

Can you give me a little more detail as to how to code this?

i get the premise of what you are doing but i am not sure exactly how

to achieve getting the file name of the linked object to the draft file and

then changing its revision.

 

Thank again

Re: vba change revision property

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Here ya go. I also attached the Excel spreadsheet I used in creating the sample.

 

Option Explicit

Sub UpdateModelLinks()
    Dim objApplication As SolidEdgeFramework.Application
    Dim objDraftDocument As SolidEdgeDraft.DraftDocument
    Dim objPropertySets As SolidEdgeFramework.PropertySets
    Dim objProperties As SolidEdgeFramework.Properties
    Dim objProperty As SolidEdgeFramework.Property
    Dim objModelLinks As SolidEdgeDraft.ModelLinks
    Dim objModelLink As SolidEdgeDraft.ModelLink
    Dim i As Integer
    Dim strRevision As String
    
    Set objApplication = GetObject(, "SolidEdge.Application")
    Set objDraftDocument = objApplication.ActiveDocument
    Set objPropertySets = objDraftDocument.Properties
    Set objProperties = objPropertySets.Item("ProjectInformation")
    Set objProperty = objProperties.Item("Revision")
    
    strRevision = objProperty.Value
    
    Set objModelLinks = objDraftDocument.ModelLinks
    
    For i = 1 To objModelLinks.Count
        Set objModelLink = objModelLinks.Item(i)
        Call UpdateModelLink(objModelLink, strRevision)
    Next
        
    Set objModelLink = Nothing
    Set objModelLinks = Nothing
    Set objProperty = Nothing
    Set objProperties = Nothing
    Set objPropertySets = Nothing
    Set objDraftDocument = Nothing
    Set objApplication = Nothing
End Sub

Sub UpdateModelLink(objModelLink As SolidEdgeDraft.ModelLink, strRevision As String)
    Dim objPropertySets As SolidEdgeFileProperties.PropertySets
    Dim objProperties As SolidEdgeFileProperties.Properties
    Dim objProperty As SolidEdgeFileProperties.Property
    Dim strFileName As String
    
    strFileName = objModelLink.Filename
    
    Set objPropertySets = New SolidEdgeFileProperties.PropertySets
    
    Call objPropertySets.Open(strFileName, False)
    
    Set objProperties = objPropertySets.Item("ProjectInformation")
    Set objProperty = objProperties.Item("Revision")
    
    objProperty.Value = strRevision

    Call objPropertySets.Save
    Call objPropertySets.Close
    
    Set objProperty = Nothing
    Set objProperties = Nothing
    Set objPropertySets = Nothing
End Sub
Jason Newell
Applications Architect
www.jasonnewell.net

Re: vba change revision property

Experimenter
Experimenter

Jason Newell you are the man.

Thank you very much sir.... works like a charm!

 

Thanks also BalamuruganM for you help as well.

 

Re: vba change revision property

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

You're welcome. I just do it for the kudos Smiley Happy

Jason Newell
Applications Architect
www.jasonnewell.net

Re: vba change revision property

Experimenter
Experimenter

Jason,

 

I have been working with programming SE with VB.Net for a few months. For an application I am designing, I need to access the date on which a part was created. I have been pulling info from a custom properties date field but this date is not acurate. (The date I am pulling does not get updated with new part number generation).

 

I would like to be able to get the following property but do not know the strings to put into the Item property.

1.JPG

 

This is what I tried and I couldn't find anything to point me in the right direction for non-Custom property fields.

objProperties = objPropertySets.Item("General")
objPropertytitle = objProperties.Item("Created")

Thanks for your help,

-GDH

 

"Automation is to Manufacturing as Programming is to Engineering"

Re: vba change revision property

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hello,

 

the file creation and last modified date are part of the standard windows file attributes and not of any file properties. You may use the .Net FileInfo object to access the date information.

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: vba change revision property

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

What Wolfgang said.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: vba change revision property

Experimenter
Experimenter
Thanks for the post. Didn't end up using that date but the info is good to know for future applications!
"Automation is to Manufacturing as Programming is to Engineering"