Get handle of Modeldoc2 without opening.
Get handle of Modeldoc2 without opening.
(OP)
Hi,
I am hopeing someone can help me with this.
I am looping through an assemblies parts getting some information about each part, which works fine. What i am not able to do is specify which part I want to have the handle on. If the part that I currently have the on is a mirrored part then I need to get the handle on the part that the mirrored part is referenced to, then move the handle back to the mirrored part and continue looping the assembly. I do not want to open the part in its own window.
I want swModelTemp to equal PartName. swModelTemp is declared as ModelDoc2 and PartName is declared as String.
I have tried many different ways to do this but have had no luck.
Thanks for any help.
I am hopeing someone can help me with this.
I am looping through an assemblies parts getting some information about each part, which works fine. What i am not able to do is specify which part I want to have the handle on. If the part that I currently have the on is a mirrored part then I need to get the handle on the part that the mirrored part is referenced to, then move the handle back to the mirrored part and continue looping the assembly. I do not want to open the part in its own window.
I want swModelTemp to equal PartName. swModelTemp is declared as ModelDoc2 and PartName is declared as String.
I have tried many different ways to do this but have had no luck.
Thanks for any help.






RE: Get handle of Modeldoc2 without opening.
You know the filename (and path?) of the ModelDoc that you want, stored as a string in variable PartName.
You want to get the ModelDoc object corresponding to that file (which may or may not be open already, possibly in its own window or possibly in the background), but you don't want it to open in its own window.
Is that correct?
-handleman, CSWP (The new, easy test)
RE: Get handle of Modeldoc2 without opening.
So if it worked if would like to say: swModelTemp = PartName
RE: Get handle of Modeldoc2 without opening.
-handleman, CSWP (The new, easy test)
RE: Get handle of Modeldoc2 without opening.
RE: Get handle of Modeldoc2 without opening.
If you only want to access custom properties, google DSOFile.
-handleman, CSWP (The new, easy test)
RE: Get handle of Modeldoc2 without opening.
varComponents = swAss.GetComponents(False)
For i = 0 To swAss.GetComponentCount(False) - 1
Set swComponent = varComponents(i)
Set swModelTemp = swComponent.GetModelDoc
Next i
Now inside that for loop i could loop through the features of swModelTemp without loading swModelTemp.
Now how could I specify which component swModelTemp is suppose to be ?
RE: Get handle of Modeldoc2 without opening.
You can set the SldWorks::DocumentVisible flag to False prior to using OpenDoc. That will load the document into memory without giving it its own window. Just be sure to set it back to True immediately, or files that the user tries to open later will not be visible. You should also have an error handling routine to set it back to True in case the macro crashes during opening of the file. You could have found this information in the API help for OpenDoc6 or OpenDoc7.
-handleman, CSWP (The new, easy test)
RE: Get handle of Modeldoc2 without opening.
I did not fully understand how that worked. I had previously looked in the SW help for opening parts but did not understand it right. That works great.