Cancel
Showing results for 
Search instead for 
Did you mean: 

Keep assembly document open

Builder
Builder

Hi Edge API Developers...

 

I have one question for you guys.
I think it's easy, but...It's too hard for me.

 

My purpose is to open the .asm extension
The rest of the files are open-update-save-close.

 

Below is my full code.

            objapp = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
            objasm = TryCast(objapp.ActiveDocument, SolidEdgeAssembly.AssemblyDocument)
            odocs = objapp.Documents

            Select Case objapp.ActiveDocumentType
                Case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument
                    occurrences = objasm.Occurrences '원래는 이건데..objapp.Occurrences

                    '이미처리된 어커런스 파일네임 저장소 (이부분은 중복된 어커런스네임을 기억하고 반복처리하지 않기 위함이다.)
                    Dim ProcessedOccurrenceFileNames = New List(Of String)
                    Dim i As Integer

                    For i = 1 To occurrences.Count Step 1
                        occurrence = occurrences.Item(i)  '1로하면 1개 i로하면 순차접근

                        If Not ProcessedOccurrenceFileNames.Contains(occurrence.OccurrenceFileName) Then

                            '처리하던대로 어커런스를 처리하십시오.
                            OccFullname = occurrence.OccurrenceFileName  '어커런스 풀네임
                            ExtName = IO.Path.GetExtension(OccFullname) '어커런스 파일명에서 확장자 추출
                            DFTname = IO.Path.ChangeExtension(OccFullname, "DFT") '어커런스네임에서 확장자 변경

                            Select Case ExtName
                                Case ".asm"  '현재는 이부분을 처리하면 문제가 발생함.
                                    objasm = objapp.Documents.Open(OccFullname)
                                Case Else
                                    If File.Exists(DFTname) Then
                                        objdoc = objapp.Documents.Open(DFTname)
                                        objdoc.UpdateAll(True)
                                        objdoc.Save()
                                        objdoc.Close()

                                    Else
                                        seDFTdoc = objapp.Documents.Open(Path33 + "Quick Sheet XY.DFT")
                                        seDFTdoc.PopulateQuicksheetTemplate(OccFullname)
                                        seDFTdoc.SaveAs(DFTname)

                                    End If

                            End Select
                        End If

                    

dark, underlined parts of the code

 

My purpose is to open asmfiles,
It's about opening a single item, storing it, and closing it.

But this code also closes the asmfile. ..~~~~
I'd appreciate it if someone would let me know the solution.

 

6 REPLIES 6

Re: Keep assembly document open

Gears Phenom Gears Phenom
Gears Phenom

@Hclee1    have you stepped thru your code to see that indeed an assembly is found and opened?  if so,  after being opened, at what line of code is it being closed?

Matt Johnson
Solid Edge Certified Professional
Solid Edge 2019 (SEEC) - Production
NX12 (Tc Integration)
Teamcenter 10.1.7

Re: Keep assembly document open

Builder
Builder

hi @Johnson_BigMatt 

vb.net When running in net debug mode one by one, there is no error.
But if you run it at once, you have a problem.

And when solidEdge assembly document is saved as a parasolid file and applied to newly opened document, it works normally.

This makes it harder to find.
Because there are times when it's working properly.

The code part is the objdoc.close() Syntax. If you don't execute this part, it's only open and not closed...

However, if this Syntax is executed, Asm file will not be opened.

Highlighted

Re: Keep assembly document open

Gears Phenom Gears Phenom
Gears Phenom

@Hclee1 

 

if you can step edit without issue but at runtime, the results are not as expected...   I'm guessing you need some processing time is there somewhere... 

 

Consider the use of ApplicationObject.DoIdle() after SE Events that need time to process...  IE:  Close, Save, Etc... 

Matt Johnson
Solid Edge Certified Professional
Solid Edge 2019 (SEEC) - Production
NX12 (Tc Integration)
Teamcenter 10.1.7

Re: Keep assembly document open

Builder
Builder

@Johnson_BigMatt 

Wow~

 

application.DoIdle()

 

I solved the problem by applying it to the bottom of my code.
However, this Not seem to speed up each document.

 

 

Re: Keep assembly document open

Gears Phenom Gears Phenom
Gears Phenom

@Hclee1   Great!   DoIdle will not speed up the processing of your code.   Rather it tells the code to wait for SE to finish what it's doing before proceeding to the next line...

 

IE:   Close, DoIde  =  wait for the doc to close before proceeding... 

 

this is not expected to speed the processing, rather allow time for processing... 

 

 

Matt Johnson
Solid Edge Certified Professional
Solid Edge 2019 (SEEC) - Production
NX12 (Tc Integration)
Teamcenter 10.1.7

Re: Keep assembly document open

Builder
Builder

@Johnson_BigMatt 

Yes. Because of this code, I thought about how I should handle it.
Thank you very much.^^