Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Automating the Rollback Bar 2

Status
Not open for further replies.

JJCPE

Mechanical
Dec 31, 2003
14
I'm making substantial changes to a set of complicated parts (that someone else designed, but it’s now up to me to make the changes).

Moving the rollback bar helps me to understand how the part was constructed, but it would be even more helpful to see the part built step by step in sort of a slide show presentation.

Clicking and dragging the bar feature by feature is getting old.

Does anyone know how to do this (is there some tip I’ve yet to stumble upon, or a method someone’s developed)?

John

 
Replies continue below

Recommended for you

I think that this is a good case of "when in doubt read the intructions".

I you click on Help and then use the index to find "rollback" it will tell you all about this.

BTW: That's what I just did to get you this answer 'cos I did not remember the details. Even tested it out too - took me all of about 45 seconds.

From 2003 on you can right click any feature in the the feature manager tree and select Rollback. In the already rolled back state you can right click it and either roll to end or roll to previous state, etc. (so you can jump around) - it's quite versatile.



Be naughty - save Santa a trip.
 
Hmm, I think this is a good case of 'read the question'.

Or perhaps I wasn't clear, so let me try again.

I know I can 'jump around', by either dragging the rollback bar to anywhere in the feature manager tree, or selecting a feature, right clicking it, and selecting roll back, or roll forward.

But I've got a model that someone else created with about 200 features. That's a lot of features to drag or click to.

What I'm looking for is a way to have the rollback bar step through the feature tree, one feature at a time, pausing for a few seconds on each, displaying the result of the various features.

It would be sort of like a movie (but much faster) that would reveal the 'growth' of the model as it went through each of it's development stages.

That way, I could put 'Cut-Extrude57' in context.

So I ask again, anyone know how to do this? Anyone written a VBA program to do this?

Thanks in advance,

John
 
I have to do this quite frequently & have found the best way is to take the time & step through each feature in sequence & rename it to something recognizable (like Gizmo Locating Boss) as I go. That way I, or anyone else, will be able to understand the model the next time it is viewed. In new models, I always give descriptive names to features, as I create them, to avoid the problem you are now having.

If you use a macro or VBA program to run through the sequence, you will probably be no further ahead...unless you have a photographic memory and remember what each generically named feature is.

[cheers]
CorBlimeyLimey
Barrie, Ontario
faq559-863
 
That's what I typically do, and I also gather features together in folders, and rearrange the order if need be.

This is the first time I've encountered such a complicated part however, and the sheer size of the feature count (200 +) has got me sloughing through it (not to mention that it's just one part in a multipart plastic housing design).

I'd put a macro in such an automated system with a run, stop and pause button. I could then run through the tree, find a particular feature I've got to change, stop the automation and go.

I've just finished three 10 hours days of renaming features and ordering them in folders, and now have to repeat the process for the other 'half' of the case design - aagh!
 
Aha! my apologies for not undestanding your problem. Well, I will ask our API Guru if there is a way to do this. He has done a lot of parsing the feature tree and some renaming on the fly too, so that bit should be easy.

I was - and he did. So at least I didn't get coal.....
OK, OK, It's a reference to my holiday sig. "Be naughty - Save Santa a trip..."
 
maybe this is over simplifying your need but you can go to the feature manager under tools options and turn on arrow key navigation. now when the rollback bar is selected you can use the up and down arrow keys to move it up and down the tree. maybe that would help in the short term.

Daniel
 
' This code is off the SW website ...


'-----------------------------------
' How to playback a model
'
' Problem:
' For a complicated part/assy, it is often very instructive
' to proceed, step by step, through the history tree.
' This shows each step of how the model was developed and
' can give insight into the design intent of the user.
'
' This sample code shows how to step through the history
' tree of a model by rolling back to each feature in
' reverse sequence. As each feature is played back, it
' is highlighted in the graphics window.
'
' Preconditions:
' 1) a part or assy is open
'
' Postconditions:
' none
'
' Notes:
' 1) delay between steps is set at 1 second
'
' Further Work:
' 1) zoom to each feature:
' Part/AssemblyDoc::FeatureByName
'
' Feature::GetBox
' ModelDoc2::ViewZoomTo2
' or
' Feature::Select2
' ModelDoc2::ViewZoomToSelection
'
' probably also require some view manipulation...

Option Explicit

Public Enum swDocumentTypes_e
swDocNONE = 0 ' Used to be TYPE_NONE
swDocPART = 1 ' Used to be TYPE_PART
swDocASSEMBLY = 2 ' Used to be TYPE_ASSEMBLY
swDocDRAWING = 3 ' Used to be TYPE_DRAWING
swDocSDM = 4 ' Solid data manager.
End Enum

Public Enum swMoveRollbackBarTo_e
swMoveRollbackBarToEnd = 1
swMoveRollbackBarToPreviousPosition = 2
swMoveRollbackBarToBeforeFeature = 3
swMoveRollbackBarToAfterFeature = 4
End Enum

Sub main()
' delay in seconds
Const DELAY As Single = 1#

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim swAssy As SldWorks.AssemblyDoc
Dim swFeatMgr As SldWorks.FeatureManager
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.feature
Dim vFeatFace As Variant
Dim swFace As SldWorks.face2
Dim sFeatName() As String
Dim sNow As Single
Dim nDocType As Long
Dim i As Long
Dim j As Long
Dim bRet As Boolean


Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swFeatMgr = swModel.FeatureManager
Set swFeat = swModel.FirstFeature

nDocType = swModel.GetType
Select Case nDocType
Case swDocPART
Set swPart = swModel

Case swDocASSEMBLY
Set swAssy = swModel
End Select


ReDim sFeatName(0)

Do While Not swFeat Is Nothing
sFeatName(UBound(sFeatName)) = swFeat.Name

ReDim Preserve sFeatName(UBound(sFeatName) + 1)

Set swFeat = swFeat.GetNextFeature
Loop

' loop will over allocate array by one,
' so remove last (empty) entry
ReDim Preserve sFeatName(UBound(sFeatName) - 1)


' now playback each feature in the FMT
For i = 0 To UBound(sFeatName)
Debug.Print sFeatName(i)

bRet = swFeatMgr.EditRollback(swMoveRollbackBarToAfterFeature, sFeatName(i))

' do not assert since may be trying to rollback/forward
' to a feature which cannot be rolled back/forward to
' eg Lighting or Annotations folder
'Debug.Assert bRet

' will remove any previous highlights
swModel.GraphicsRedraw2


' highlight feature if it has any geometry
Select Case nDocType
Case swDocPART
Set swFeat = swPart.FeatureByName(sFeatName(i))

Case swDocASSEMBLY
Set swFeat = swAssy.FeatureByName(sFeatName(i))
End Select

vFeatFace = swFeat.GetFaces
If Not IsEmpty(vFeatFace) Then
For j = 0 To UBound(vFeatFace)
Set swFace = vFeatFace(j)

swFace.Highlight True
Next j
End If


' only pause if we have successfully rolled back
If True = bRet Then
sNow = Timer
While sNow + DELAY > Timer
' need to allow SW to refresh screen
DoEvents
Wend
End If
Next i

' remove highlight from last feature
swModel.GraphicsRedraw2
End Sub
'-----------------------------------

 
Thanks to both rocheey and danielgraham for thier posts.

Daniel's, while simple, is a big improvement over clicking and dragging.

There is so much functionality in the SolidWorks User interface, I've stopped being amazed at being shown aspects of it that I didn't know existed.

As to rocheey, the same applies, the VBA code was just what I needed (at the beginning of the effort), though I didn't think to puruse the SW site.

Thanks again,

John

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor