Displaying Tempo Configurations

Hello

I make a macro to create an "animation" allowing me to see a succession of modifications and configuration changes. I'm attaching some of the code. My problem is that the image does not update (display). The code is taken into account but on the screen there is only the first and last step that are visible despite the "boolstatus = Part.ForceRebuild3(True)". 

Do you have an idea?

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

 Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds as LongPtr) 'For 64 Bit Systems


Sub main()
Dim i As Single
Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView

'Config Selection
boolstatus = Part.Extension.SelectByID2("Small [55-145mm]", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.ShowConfiguration2("Small [55-145mm]")
'boolstatus = Part.ForceRebuild3(True)

Wait

For i = 0.055 To 0.145 Step 0.005
boolstatus = Part.Extension.SelectByID2("", "FACE", 1.88162450943423E-02, 2.07610918535579E-02, 3.41903065946383E-02, False, 0, Nothing, 0)
Part.ActivateSelectedFeature
boolstatus = Part.Extension.SelectByID2("L inter épau@Sketch1@Flex_flexible-1@EX10610_00000_10_boni", "DIMENSION", 0.516914003349862, 0.726763465357772, 0.299002280968981, False, 0, Nothing, 0)
Dim myDimension As Object
Set myDimension = Part.Parameter("L inter épau@Sketch1@Flex_flexible. Part")
myDimension.SystemValue = i
Part.ClearSelection2 True
boolstatus = Part.ForceRebuild3(True)
Set myModelView = Part.ActiveView
Wait
Next i

'boolstatus = Part.Extension.SelectByID2("Medium [145-170mm]", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
'boolstatus = Part.ShowConfiguration2("Medium [145-170mm]")
'boolstatus = Part.ForceRebuild3(True)
'Wait

'boolstatus = Part.Extension.SelectByID2("Large [>175mm]", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
'boolstatus = Part.ShowConfiguration2("Large [>175mm]")
'boolstatus = Part.ForceRebuild3(True)
'For i = 0.055 To 0.145 Step 0.005

'boolstatus = Part.Extension.SelectByID2("Small@Flex_flexible. SLDPRT", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
'boolstatus = Part.ShowConfiguration2("Small")
'boolstatus = Part.Extension.SelectByID2("L inter épau@Sketch1@Flex_flexible. SLDPRT", "DIMENSION", -7.48434662003883E-02, 0.151717758326748, -7.54569406310026E-02, False, 0, Nothing, 0)
'Dim myDimension As Object

 

'Set myDimension = Part.Parameter("L inter épau@Sketch1")
'myDimension.SystemValue = i
'boolstatus = Part.ForceRebuild3(True)
'Wait
'boolstatus = Part.EditRebuild3()
'Next i

End Sub


   

Sub Wait()
Sleep 200
End Sub

 

 

 

Hello

Are there breaks between each "movement"?

If not, you have to put it.

If so, try to lengthen them.

Example of a break:

1)

Application.Wait Time + TimeSerial(0, 0, 5) 

2)

Declare Sub Sleep Lib "kernel32" aka "Sleep" (ByVal dwMilliseconds As Long)

 

Sleep 1000

How about using the SolidWorks Motion utility?

See here:

https://www.youtube.com/watch?v=0OT5_ZWrFQM

2 Likes

@.PL: Yes, my wait function is actually a sleep. I've tried increasing these pauses but the changes from one length to another still don't show up. 

You can try setting EnableGraphicsUpdate to true:

http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IModelView~EnableGraphicsUpdate.html

Or even in the meantime, put an IF loop to change EnableGraphicsUpdate to false and then true.

1 Like