Updating model links from a draft file?

Experimenter
Experimenter

Hello,

 

I am very new to programming with V.B. for SolidEdge.

I want to create a macro that will "update all links" of a model from the draft environment.

We get drafts with the dark borders in the corners & I'm looking for a faster way to update them.

I really have no clue where to start, can anyone help?

 

Thanks,

Mark

6 REPLIES

Re: Updating model links from a draft file?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

You won't update the model links. The view borders have dark borders to indicate that the model links have been changed and you only need to update the views to reflect the changes in the model.

'-----------------------------------------------------------
' Update all views in a draft document
'-----------------------------------------------------------
Dim objDoc As DraftDocument = objApp.ActiveDocument
For Each objSheet As Sheet In objDoc.Sheets
  For Each objView As DrawingView In objSheet.DrawingViews
    objView.Update()
  Next
Next

 

Re: Updating model links from a draft file?

Experimenter
Experimenter

Martin,

 

Thank you for the reply!  I see what you are doing in the code (thanks for that)

But what I needed to do is update the model that the view is derived from…

So if in native SE I would have to 2x click the view, then activate all, then update all, save, then close to return to the draft… and then I could update all draft views…  but I need to make sure the model itself is fully up to date.

 

It is my understanding that the light grey border that completely surrounds views indicates the view is out of date, but the dark corners on the view indicate that the underlying model itself needs updated.

 

With the help of a co-worker who does programming everyday. We were able to create a macro that will open the model from a draft environment, update the links, then return to the draft and finally update the drawing views.

 

Thanks again for the help, it is much appreciated!

Re: Updating model links from a draft file?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The following code may do what you want:

'----------------------------------------------------------------------
' Update all model links in a draft document
'----------------------------------------------------------------------
Dim objDoc As DraftDocument = objApp.ActiveDocument
For Each objMdl As ModelLink In objDoc.ModelLinks
  Dim nFiles As Integer = 0
  Dim files2Update(0) As String
  objMdl.GetFilesToUpdate(nFiles, files2Update)
  objApp.Interactive = False
  objApp.ScreenUpdating = False
  For Each strFile In files2Update
    Dim objSEDoc As SolidEdgeDocument = objApp.Documents.Open(strFile)
    If objSEDoc.Type = DocumentTypeConstants.igAssemblyDocument Then
      objSEDoc.ActivateAll()
      objSEDoc.UpdateAll()
    End If
    objSEDoc.Save()
    objSEDoc.Close()
  Next
  objApp.Interactive = True
  objApp.ScreenUpdating = True
  ' Update all views with that model link
  objMdl.UpdateViews()
Next

 

Re: Updating model links from a draft file?

Experimenter
Experimenter

Martin,

 

What do these two lines do? Do I need to declare them?

objApp.Interactive = False
  objApp.

Thanks,

Mark

Re: Updating model links from a draft file?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

For performance reasons and to avoid a flashing screen, these two lines are to switch off the interactive mode and to switch off the screen updating.

After all documents are updated and saved, I switch on the interactive mode and screen updating again.

You may comment out the two lines to see the effect when the documents are opened, updated, and saved.

Re: Updating model links from a draft file?

Experimenter
Experimenter

Thanks for all your help today. I'm out of the office this afternoon, so I will give this a shot tomorrow. This looks very promising for what we want to achieve.

 

Thanks again!