Sunday, February 05, 2012
Product Configurator / Draft Automation
Last Post 09 Feb 2010 12:24 PM by harry. 12 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
John SlipecUser is Offline
New Member
New Member
Posts:15

--
06 Oct 2005 01:47 PM  
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

Try
objApp = Marshal.GetActiveObject("SolidEdge.Application")
Catch
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
objLink.UpdateViews()
objDraft.Save()


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
Jason NewellUser is Offline
Site Owner
Advanced Member
Advanced Member
Posts:895
Avatar

--
06 Oct 2005 02:13 PM  
John,

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)
objModelLink.UpdateViews()
Next

End Sub

End Module
Jason Newell
Applications Architect
www.jasonnewell.net
John SlipecUser is Offline
New Member
New Member
Posts:15

--
06 Oct 2005 02:33 PM  
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."

Jason NewellUser is Offline
Site Owner
Advanced Member
Advanced Member
Posts:895
Avatar

--
06 Oct 2005 05:47 PM  
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.
Jason Newell
Applications Architect
www.jasonnewell.net
harryUser is Offline
New Member
New Member
Posts:7

--
04 Feb 2010 03:31 AM  

Hello,

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.

harryUser is Offline
New Member
New Member
Posts:7

--
04 Feb 2010 03:32 AM  

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"

ErWoUser is Offline
New Member
New Member
Posts:37

--
08 Feb 2010 03:56 AM  

Hello Harry,

This Code works. Let me know if your problem is'nt solved.

Public Sub UpdateDraft()
On Error Resume Next
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgeDraft.DraftDocument
Dim objSheet As SolidEdgeDraft.Sheet
Dim objDrawingViews As SolidEdgeDraft.DrawingViews
Dim objDrawingView As SolidEdgeDraft.DrawingView
Dim DrawingViewNeedsUpdate As Boolean
'Get SE en open document
    Set objApp = GetObject(, "SolidEdge.Application")
    If Err Then
        Err.Clear
        Set objApp = CreateObject("SolidEdge.Application")
    End If
    'Open document
    Set objDoc = objApp.ActiveDocument
   
    'Visible
    objApp.Visible = True
    objApp.DisplayFullScreen = True
   
'Set
    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
        Else
            DrawingViewNeedsUpdate = False
        End If
    Next
   
'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)

SandeepUser is Offline
New Member
New Member
Posts:19

--
08 Feb 2010 10:53 PM  

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

harryUser is Offline
New Member
New Member
Posts:7

--
09 Feb 2010 01:49 AM  
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?
JRUser is Offline
New Member
New Member
Posts:91

--
09 Feb 2010 05:16 AM  
before you open the drawing you can switch all alerts off:
objApp.DisplayAlerts=False
harryUser is Offline
New Member
New Member
Posts:7

--
09 Feb 2010 05:46 AM  
yes i know, but i want to hide just this "update views" message.
Is that possible?
ErWoUser is Offline
New Member
New Member
Posts:37

--
09 Feb 2010 09:04 AM  

Hi Harry,

I don't know a way to hide that specific warning. But what you can do is what John says; set DisplayAlerts to False. Then, when Solid Egde has fired the 'AfterDocumentOpen' event (see Solid Edge Spy), you can set the DisplayAlerts property back to True.

Good luck,

Best Regards,

Wouter (Erwo)

p.s. I'am indeed from the Netherlands, sent me an email for contact information. 

harryUser is Offline
New Member
New Member
Posts:7

--
09 Feb 2010 12:24 PM  
Thats wat i already did in my code.
but i guess i will have to keep it that way, for now ;)

Thanks anyway, JR and ErWo.
You are not authorized to post a reply.

Active Forums 4.2
Copyright © 2011 JasonNewell.NET