Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock and Unlock external references

Status
Not open for further replies.

Diemaker1

Mechanical
Apr 6, 2006
33
Is there a quick way to Lock and Unlock external references on ALL parts in an assembly?

I created parts within an assy using the master sketch method. Master was drawn in CLOSED position. Now I want to make a config in the OPEN position… but of course parts are all tied to the master and moving them wacks everything. Parts can be moved by locking the external references. Fine. But do you have to unlock/lock each part? One by one? Is there an obscure command somewhere that does this?

Maybe the best way to do this is make another assy. In previous jobs I’ve been drawing most of the parts in a multibody then splitting them off and making a new assy that moves. This job was too complicated for multibody. So I went the assy route. I was hoping to get it to move and not have to create another assy.
 
Replies continue below

Recommended for you

Make a new config and then change the controlling dimensions using the This Configuration Only option.

Take a look at cwsinks assy posted in "Extrude to surface not updating in assy's" thread559-171700 for an example.



[cheers]
 
CorBlimeyLimey,

This will work for your dimensions only. But I am sure DieMaker1 has converted edges and is mating die details to surfaces, etc; when creating his forms in the tool.

Open the die, the strip stays at die level and all your punches, etc, get stretched as they are still tied to the strip at die level. Or as your strip moves up on the lifters you get other weird things happening.

Diemaker,

Do you really want to break all the references, or just the offending one's that cause you issues when you show the different positions of the tool? I would just lock the references in the parts that are necessary.

I suspect one of the peeps here can write you a macro routine that would run the assembly tree and lock/unlock all the references for you. Or maybe make it so you can multi-select the components you want to lock/unlock and have the macro only loop through those components.

That would be a handy macro if it is not out there already.

Regards,

Anna Wood
SW06 SP5 x64, WinXP x64
Dell Precision 380, Pentium D940, 4 Gigs RAM, FX3450
WD Raptors, 1 Gb network connection
 
Your both right. Lots of parts use converted sketches and extrude to vertices using the sketch vertices. But the sketches are controlled by dims that could be configed as CBL said.

I think CBL’s suggestion would be the way to do it. Unfortunately I didn’t set up the master sketch to open and close, so it would be a mess to do that now. There is a “master part” in there too providing terminating surface for top and bottom tools. That would have had to be 2 parts. Maybe next time.

Anna, I don’t want to break the refs, just lock them. Then I can move the top up, open the cams, move sprung items, check for feed clearances… and this isn’t a whole die, just one form station. I model form stations separately like individual molds. I was hoping to debug it complete before dropping it into the final assy. which totals 140” x 60”. Final assy won’t be fast as fluid by any means.

A global Ref Toggle seems like what I need, but there would be problems. Many parts that move together are only connected thru the master, so I’d have to mate them together as one. And configs don’t respect lock ref settings so I’d have to remember to lock them before changing configs or the whole tree would turn red… maybe the reason SW didn’t provide a global ref lock toggle is because it could be easily abused.
 
There is a macro I got from the SW API Help, I made it into 2 macros...one for lock and one for unlock. You can either map a key or make a button on the macro's toolbar to quickly call these. I have not used it a lot, but so far it does work ok.
Ken

Code:
'***Lock*** Version
'Lock All External References Example (VB)
'This example shows how to lock all external references in a part or an assembly in reverse chronological order.
 
'---------------------------------------
'
' Preconditions: Part or assembly is open.
'
' Postconditions: All external references are locked.
'
'---------------------------------------

Option Explicit

Sub ProcessModel(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, sPadStr As String)
    If UnlockReferences Then
        Debug.Print sPadStr & "  Unlocking: " & swModel.GetPathName
        swModel.UnlockAllExternalReferences
    Else
        Debug.Print sPadStr & "  Locking: " & swModel.GetPathName
        swModel.LockAllExternalReferences
    End If

End Sub

Sub ProcessComponent(swApp As SldWorks.SldWorks, swComp As SldWorks.Component2, sPadStr As String)
    Dim vChildCompArr               As Variant
    Dim vChildComp                  As Variant
    Dim swChildComp                 As SldWorks.Component2
    Dim swChildModel                As SldWorks.ModelDoc2
    
    vChildCompArr = swComp.GetChildren
    For Each vChildComp In vChildCompArr
        Set swChildComp = vChildComp
        
        Debug.Print sPadStr & swChildComp.Name2
        
        ProcessComponent swApp, swChildComp, sPadStr & "  "
    
        Set swChildModel = swChildComp.GetModelDoc
        
        ProcessModel swApp, swChildModel, sPadStr
    Next vChildComp
End Sub

Sub main()
    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim swAssy                      As SldWorks.AssemblyDoc
    Dim swConfigMgr                 As SldWorks.ConfigurationManager
    Dim swConf                      As SldWorks.Configuration
    Dim swRootComp                  As SldWorks.Component2
    Dim nStatus                     As Long
    Dim bRet                        As Boolean
    Dim UnlockReferences As Boolean
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swConfigMgr = swModel.ConfigurationManager
    Set swConf = swConfigMgr.ActiveConfiguration
    Set swRootComp = swConf.GetRootComponent

    UnlockReferences = False
    
    Debug.Print "File = " & swModel.GetPathName
    
    Select Case swModel.GetType
        Case swDocPART
            ProcessModel swApp, swModel, "  "
    
        Case swDocASSEMBLY
            Set swAssy = swModel
            nStatus = swAssy.ResolveAllLightWeightComponents(False)
            
            Set swRootComp = swConf.GetRootComponent
            
            ProcessComponent swApp, swRootComp, "  "
            
        Case Else
            Exit Sub
    End Select

End Sub

Code:
'***Unlock*** Version
'Lock All External References Example (VB)
'This example shows how to lock all external references in a part or an assembly in reverse chronological order.
 
'---------------------------------------
'
' Preconditions: Part or assembly is open.
'
' Postconditions: All external references are locked.
'
'---------------------------------------

Option Explicit

Sub ProcessModel(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, sPadStr As String)
    If UnlockReferences Then
        Debug.Print sPadStr & "  Unlocking: " & swModel.GetPathName
        swModel.UnlockAllExternalReferences
    Else
        Debug.Print sPadStr & "  Locking: " & swModel.GetPathName
        swModel.LockAllExternalReferences
    End If

End Sub

Sub ProcessComponent(swApp As SldWorks.SldWorks, swComp As SldWorks.Component2, sPadStr As String)
    Dim vChildCompArr               As Variant
    Dim vChildComp                  As Variant
    Dim swChildComp                 As SldWorks.Component2
    Dim swChildModel                As SldWorks.ModelDoc2
    
    vChildCompArr = swComp.GetChildren
    For Each vChildComp In vChildCompArr
        Set swChildComp = vChildComp
        
        Debug.Print sPadStr & swChildComp.Name2
        
        ProcessComponent swApp, swChildComp, sPadStr & "  "
    
        Set swChildModel = swChildComp.GetModelDoc
        
        ProcessModel swApp, swChildModel, sPadStr
    Next vChildComp
End Sub

Sub main()
    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim swAssy                      As SldWorks.AssemblyDoc
    Dim swConfigMgr                 As SldWorks.ConfigurationManager
    Dim swConf                      As SldWorks.Configuration
    Dim swRootComp                  As SldWorks.Component2
    Dim nStatus                     As Long
    Dim bRet                        As Boolean
    Dim UnlockReferences As Boolean
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swConfigMgr = swModel.ConfigurationManager
    Set swConf = swConfigMgr.ActiveConfiguration
    Set swRootComp = swConf.GetRootComponent

    UnlockReferences = True
    
    Debug.Print "File = " & swModel.GetPathName
    
    Select Case swModel.GetType
        Case swDocPART
            ProcessModel swApp, swModel, "  "
    
        Case swDocASSEMBLY
            Set swAssy = swModel
            nStatus = swAssy.ResolveAllLightWeightComponents(False)
            
            Set swRootComp = swConf.GetRootComponent
            
            ProcessComponent swApp, swRootComp, "  "
            
        Case Else
            Exit Sub
    End Select

End Sub
 
DieMaker1,

Opps... Yes, I meant to say lock the references. I agree no value in breaking them, locking is the way to go so you can bring them back to life.

I think it is really smart setting up each of the stations as sub assemblies. Will make for easier work since you will have a pretty big top level asm.

KenBolen (Thanks Ken!) looks to have a couple macros you could use. Now it is a matter of figuring out the best master sketch technique so you can efficiently work with your moving parts the way you would like.

Have you looked at sketch blocks? I think that may be of use to you also. I know that is something I need to investigate more for our designs we do.

Regards,

Anna Wood
SW06 SP5 x64, WinXP x64
Dell Precision 380, Pentium D940, 4 Gigs RAM, FX3450
WD Raptors, 1 Gb network connection
 
Super thanks KenB. I’m still ignorant of how to implement VB but when I get some time…

Doing the next station with a master that can be driven open with dims. Looks like it will work, got to dimension it from the outside in instead of the more intuitive inside out.

One hassle… you can’t dimension something “0”. A lot of my movements bottoms against other blocks. Using a sketch block for a moving part, I would like to dimension it “0” against the bottoming block in one config. Then change the dim to “1.00” to move it 1.0 in another config. I’m using a very small number to represent 0, but it ain’t zero, yaknow.

Anne, I use sketch blocks on parts that move. But not for all blocks like they show in demos where parts are auto created from the blocks. Starting with nothing, there’s too much changing and tweaking of the whole design, and it’s a hassle editing a block compared to a sketch. I might change my mind about this one day.

But I do use blocks a lot for repetitive features. Sketch blocks are great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor