[MACRO] Refresh of the View

[MACRO] Refresh of the View

Anonymous
Not applicable
1,392 Views
10 Replies
Message 1 of 11

[MACRO] Refresh of the View

Anonymous
Not applicable

Hi everyone,


I'm encountering a problem with my developments ... In my macro, I hide and show some layers but somehow, the layers are "untick" but stay in the View ... somehow, the view does not refresh ... Do you have any idea on how to prevent this comportement ?


However, when I force the refreshing by showing a node layer manually, the view is refreshed ... But how to force the refreshing in my macro ?


Thank you for your help


Enjoy your day !

0 Likes
Accepted solutions (1)
1,393 Views
10 Replies
Replies (10)
Message 2 of 11

bernor_mf
Advisor
Advisor

Hi,

strange behaviour you see.

Do you see the same in Synergy 2016 and Synergy 2015?

As there were a change of layer layout in 2016. Not sure if this really affects the view update...

 

There is unfortunatley no object as Viewer.Refresh

 

Maybe you could try Viewer.Reset ?

Set Viewer = Synergy.Viewer()
Viewer.Reset

It will rotate to default position, hence update the view.

Or maybe trick the viewer to update in another way, with a small rotate or something like that?

 

Regards,

Berndt

 

 

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
0 Likes
Message 3 of 11

Anonymous
Not applicable

Hi bernor_mf !

 

Thank you for your answer however, I cannot try if my macro works on MoldFlow 2015 ...

 

However, I tried with the Viewer.Reset command but my layers still work wrongly  😞

 

Do you have any other idea ?

 

Thank you so much for your help

0 Likes
Message 4 of 11

bernor_mf
Advisor
Advisor

Hi nkelle,

are you using this kind of code:

Set LayerManager = Synergy.LayerManager()
Set EntList = LayerManager.CreateEntityList()
EntList.SelectFromString "L4 "
LayerManager.ShowLayers EntList, False

where False turns layer off and True turns it on.

 

Did a quick test, and it looks ok in graphics to use this code. It showas and hides as expected.

 

Regards,

Berndt

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
0 Likes
Message 5 of 11

Anonymous
Not applicable

Yes, I use this kind of code :

sub HideLayers(startString)
	Set LayerManager = Syn.LayerManager()

	Set L1 = LayerManager.GetFirst()
	LName = LayerManager.GetName( L1 ) 
			
	Do While LName <> ""
		LName = trim(LayerManager.GetName( L1 ))
		if Left(LName,Len(startString)) = startString then
			LayerManager.ShowLayers L1, True
			LayerManager.ShowLayers L1, False
		end if
		Set L1 = LayerManager.GetNext(L1)
	Loop		
end sub

But somehow, sometimes it doesn't work ... 

0 Likes
Message 6 of 11

bernor_mf
Advisor
Advisor
Accepted solution

 

Strange it doesn't work.

Maybe the system cannot react so fast?

I would try to add a waiting time to see if it helps, like a few seconds:

 

LayerManager.ShowLayers L1, True
WScript.Sleep 2000 '** the time in ms, milliseconds : this will wait for 2 seconds LayerManager.ShowLayers L1, False

 

Regards,

Berndt

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
Message 7 of 11

Anonymous
Not applicable

Well, it seems to be OK ... I don't know why but thank you for your solution !

0 Likes
Message 8 of 11

bernor_mf
Advisor
Advisor

So adding a waiting time resolved the refresh issue?

Did you use 2000 ms or trimmed it to shorter waiting time?

 

Just curious of the outcome.

 

Thanks.

Regards,

Berndt

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
0 Likes
Message 9 of 11

Anonymous
Not applicable

I used your preconisations :

 

WScript.Sleep 2000 '** the time in ms, milliseconds : this will wait for 2 seconds 
0 Likes
Message 10 of 11

bernor_mf
Advisor
Advisor

Thanks!

Good to know.

 

Right, seems as system needs a waiting time to be able to execute as wished.

I have seen this occasionally in other situatuions, and adding a short waiting time resolved issue.

(Another example when saving a study, a wating time could be needed before next step.)

 

As using 2 sec in loop, it might slow down execution if many layers.

I would recommend to trim the time, by testing 0.5s (500 ms) if not ok, then 1s (1000ms) and so on.

 

Regards,

Berndt

 

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
0 Likes
Message 11 of 11

Anonymous
Not applicable

Hi, 

 

I just tried 500ms, 1000ms and 1500ms and it does not work so I'll keep the 2000ms of delay 🙂