Product Configurator / Draft Automation

Hey Jason, thanks for all your (and Greg's) hard work in getting all that material together for the summit. Flying out to Cincinnati was worth it alone just for that pre-conference.


I've been tinkering with .NET and solid edge for several months now and have been semi-successful. I am trying to build a little "product configurator" for one of our new product lines. The idea is once done a customer service person could design the product without ever seeing solid edge, and produce all drawings and documentation within clicks.


I am at the point where I need to open all the draft files in my project, change some titelblock properties, update them and print them. Basically I have a collection that stores all the draft file names and then it just cycles through each one, opening them and attempting to update them. The smarter way would be to use the revision manager API's but I've already got it half coded this way. Unfortunately I couldn't find any examples on your cd where you open and update documents. Here is my code that I have a question about:



Private objApp As SolidEdgeFramework.Application

Private objDraft As SolidEdgeDraft.DraftDocument

Private objLink As SolidEdgeDraft.ModelLink



objApp = Marshal.GetActiveObject("SolidEdge.Application")


objApp = MarshalEx.CreateObject("SolidEdge.Application")

Catch ex As Exception

MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try


'Recoginze your Marshal class being utilized? Thanks again for your code at the summit!


objApp.Visible = False

objApp.Interactive = False

objApp.DisplayAlerts = False



objDraft = objApp.Documents.Open("filename.dft")

'This is the point that blows up on me

objLink = objDraft.ModelLinks





When I call upon objLink I get a "cast is invalid" type of error. I've dug through everything in my objApp and objDraft objects and cannot find any way to update these drawings.



Thanks in advance


Posted by: John Slipec
Post date: 10/6/2005 8:47:31 AM


RE: Product Configurator / Draft Automation



Good to hear from you!


I pasted some code for you below. Take a look at it and see if it's what you're needing. If not, let me know.




Imports System.Runtime.InteropServices


Module Module1


Sub Main()

Dim objApp As SolidEdgeFramework.Application

Dim objDraft As SolidEdgeDraft.DraftDocument

Dim objModelLinks As SolidEdgeDraft.ModelLinks

Dim objModelLink As SolidEdgeDraft.ModelLink

Dim i As Integer


objApp = Marshal.GetActiveObject("SolidEdge.Application")

objDraft = objApp.ActiveDocument

objModelLinks = objDraft.ModelLinks


For i = 1 To objModelLinks.Count

objModelLink = objModelLinks.Item(i)




End Sub


End Module



Posted by: Jason Newell
Post date: 10/6/2005 9:13:50 AM

RE: Product Configurator / Draft Automation

Wow thanks for the super fast response


Works like a charm! I have your code integrated and working exactly the way I need it to. I'm sure I will have more question in the near future as I try new things with .NET / solid edge.


With myself it's just like what Greg said "I don't know how to program but I do know what has worked before and how to reproduce it."




Posted by: John Slipec
Post date: 10/6/2005 9:33:15 AM

RE: Product Configurator / Draft Automation

Yeah, under 30 min .


Try and get that from UGS .


I'm teasing . UGS support is good ;-).


Glad you got the answer your were looking for.


Posted by: Jason Newell
Post date: 10/6/2005 12:47:55 PM

RE: Product Configurator / Draft Automation



I saw this topic but i had another similar question. I want to check with VB if the drawing needs a update, but i don't know how.

(And if the drawing needs an update then i can give the user a msgbox warning, update the drawing and change the filename of the pdf-file.)

I hope somebody can help me.


Posted by: harry dijk
Post date: 2/3/2010 9:31:55 PM

RE: Product Configurator / Draft Automation


Maybe I need to mention that I already tried several things but they don't work:

If objDoc.ModelLinks(1).UpdateViews = False Then MsgBox "..."

If objDoc.ActiveSheet.DrawingView(8).IsUpToDate = True Then MsgBox "True"


Posted by: harry dijk
Post date: 2/3/2010 9:32:03 PM

RE: Product Configurator / Draft Automation


Hello Harry,

This Code works. Let me know if your problem is'nt solved.Public Sub UpdateDraft()

On Error Resume NextDim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgeDraft.DraftDocument

Dim objSheet As SolidEdgeDraft.SheetDim objDrawingViews As SolidEdgeDraft.DrawingViews

Dim objDrawingView As SolidEdgeDraft.DrawingViewDim DrawingViewNeedsUpdate As Boolean'Get SE en open document

    Set objApp = GetObject(, "SolidEdge.Application")    If Err Then


        Set objApp = CreateObject("SolidEdge.Application")

    End If

    'Open document

    Set objDoc = objApp.ActiveDocument



    objApp.Visible = True

    objApp.DisplayFullScreen = True



    Set objSheet = objDoc.ActiveSheet

    Set objDrawingViews = objSheet.DrawingViews


    DrawingViewNeedsUpdate = False


'Loop throug the drawingviews and check each one of them.

'If one of the views is out of date, the Boolean is True

    For Each objDrawingView In objDrawingViews

        If objDrawingView.IsUpToDate = False Then

            DrawingViewNeedsUpdate = True

            Exit For

            DrawingViewNeedsUpdate = True


            DrawingViewNeedsUpdate = False

        End If



'Show the messagebox

    If DrawingViewNeedsUpdate = True Then

        MsgBox "Update the drawing and change the filename of the pdf-file"

    End If'Release variables

    Set objApp = Nothing

    Set objDoc = Nothing

    Set objSheet = Nothing


    Set objDrawingViews = Nothing

    Set objDrawingView = Nothing


End Sub

Best Regards,

Wouter (Erwo)


Posted by: Wouter Sloof
Post date: 2/7/2010 9:56:13 PM

RE: Product Configurator / Draft Automation


Dear John,

If you want to change the file properties or some title boxes in draft file, it doesn't require to open the file in SolidEdge simply you can use file system object and you can add Title, any custom properties etc. which will save a lot of time for opening and closing of a file in SolideEdge.

Just try with file system object.

All the Best,

Sandeep Shewale


Posted by: Sandeep Shewale
Post date: 2/8/2010 4:53:15 PM

RE: Product Configurator / Draft Automation

Thanks Wouter!


You used the same methode as i did, but with you the code worked.

So i did some more testing and this was the problem:

1) If objDoc.ActiveSheet.DrawingView(1).IsUpToDate = False Then MsgBox "False"

2) If objDoc.ActiveSheet.DrawingViews.Item(1).IsUpToDate = False Then MsgBox "False"


line 1 doesn't work, and line 2 works fine. So that was the problem. Thanks anyway

BTW are you from holland? (I am from holland)



When i open a drawing with drawingviews that are not up to date i get a warning message.

Does anybody know how to not display this message?


Posted by: harry dijk
Post date: 2/8/2010 7:49:56 PM

RE: Product Configurator / Draft Automation

before you open the drawing you can switch all alerts off:




Posted by: JR
Post date: 2/8/2010 11:16:19 PM