Hi everyone,
The topic summary pretty much describes it.
The code snippet is:
Set swAssy = swApp.OpenDoc6(strAssyToReference, swDocASSEMBLY, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
At the end the drawing, assembly, and part are all open, but theassembly is read only. I open the part and drawing in the same way:
Set swPart = swApp.OpenDoc6(strPartToReference, swDocPART, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swDrawing = swApp.OpenDoc6(strDrawingToOpen, swDocDRAWING, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
If I save the drawing and close everything (without saving changesto the assembly, because it won't allow that) then re-open theassembly from solidworks in the normal way, it opens read/write.
Any Ideas?
Thanx,
-plhSolidworksApi macros





The topic summary pretty much describes it.
The code snippet is:
Set swAssy = swApp.OpenDoc6(strAssyToReference, swDocASSEMBLY, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
At the end the drawing, assembly, and part are all open, but theassembly is read only. I open the part and drawing in the same way:
Set swPart = swApp.OpenDoc6(strPartToReference, swDocPART, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swDrawing = swApp.OpenDoc6(strDrawingToOpen, swDocDRAWING, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
If I save the drawing and close everything (without saving changesto the assembly, because it won't allow that) then re-open theassembly from solidworks in the normal way, it opens read/write.
Any Ideas?
Thanx,
-plhSolidworksApi macros

This one is going to be tough. For a test I suggest changingswOpenDocOptions_Silent to 0 (zero) and see what happens when youopen the assembly.
SA
SolidAir wrote:
Paul,
This one is going to be tough. For a test I suggest changingswOpenDocOptions_Silent to 0 (zero) and see what happens when youopen the assembly.
SA
Set swModel = swApp.OpenDoc6(strAssyToReference, swDocASSEMBLY, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
Thus using
Public swModel As SldWorks.ModelDoc
rather than
Public swAssy As SldWorks.AssemblyDoc
Nor was it effective to combine both approaches :
Set swModel = swApp.OpenDoc6(strAssyToReference, swDocASSEMBLY, _
0, "", nErrors, nWarnings)
Does anyone have any other ideas?
Thanx,
-plh
When you changed the code to
Set swModel = swApp.OpenDoc6(strAssyToReference, swDocASSEMBLY, _
0, "", nErrors, nWarnings)
did you get any messages?
The only other thing I can think of (since I cannot actually seewhat you are doing) is the file you are opening through the programthe same one (the same path and filename) you are opening the"normal" way?
Try moving the assembly to another location and open it.
SA
Just thought I'd let you know I did figure out what was wrong, butit had nothing to do with how I was opening it.
Earlier in the code I had (incidentally, this part was the subjectof an earlier topic thread):
Set swDoc = swDocMgr.GetDocument(strAssyToReference,swDmDocumentAssembly, False, nErrors)
vNames = swDoc.GetCustomPropertyNames
' Open the file as read-write.
With Me
'begin resetting of custom properties
[snip - whole buncha resettings of custom properties]
swDoc.Save
----->But then I did NOT have:
'*****************************
swDoc.CloseDoc
'*****************************
End With
So the assembly was still OPEN, when the Drawing opened up!
The clue was that there was a mouse-over tip for the assembly inthe drawing's tree, saying "Read Only/In use by system"
Thanks for all of your help both with this and other issues.
-plh