Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Rendering view switcher 1

Status
Not open for further replies.

Wuzhee

Automotive
Jul 12, 2022
269
0
0
DE
Hi,

I'd like to have a macro that switches between perspective and parallel views regardless of which workbench I'm in.
Currently I have 2 keys on my Spacemouse for each view but in Part wb the switch from perspective to parallel pops up an error.
3Dx built in command list is a complete mess for CATIA :(

I have a workbench switcher macro (posted below) which theoretically could be rewritten easily but having zero vbasic experience I don't feel the power to accomplish this by myself.

Can somebody help me?

Cheers,
Balázs


Code:
Language="VBSCRIPT"

Sub CATMain()

Dim i
i=Cint(CATIA.Documents.Count)

If i > 0 Then


On Error resume next

			Dim doc
			set doc= CATIA.ActiveDocument

              Dim curr_wb
			curr_wb =Cstr(CATIA.GetWorkbenchId)

                If curr_wb = "PrtCfg" Then 'which means part desing

                    CATIA.StartWorkbench("CATShapeDesignWorkbench")

                ElseIf curr_wb = "CATShapeDesignWorkbench" Then 'which means GSD

                    CATIA.StartWorkbench("PrtCfg")

                End If

if err.Number = 0 then
  exit sub
else
  msgbox "No files open"
end if

Else

MsgBox("No files open")

End If

End Sub
 
Replies continue below

Recommended for you

I used a different and probably simpler method for myself - I put the commands on a custom toolbar. If you create the toolbar with an empty session, then the toolbar will be present in every workbench.
 
Give this a try.



Language="VBSCRIPT"

Sub CATMain()
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
Set viewpoint3D1 = viewer3D1.Viewpoint3D


tempa = viewpoint3D1.ProjectionMode

If tempa = 0 then
'Toggle to Parallel value 1
viewpoint3D1.ProjectionMode = catProjectionCylindric
msgbox "Parallel Mode", , tempa

Else
'Toggle to Perspective value 0
viewpoint3D1.ProjectionMode = catProjectionConic
msgbox "Perspective Mode", ,tempa

End IF

End Sub
 
Wuzhee said:
3Dx built in command list is a complete mess for CATIA :(
Are you working in 3DEXPERIENCE? If yes, no chance for your code to work.
In 3DX command for the perspective view is CATAfrConicViewHdr and the parallel view is CATAfrCylindricViewHdr
So, you can use also a macro with CATIA.StartCommand("CATAfrConicViewHdr") and CATIA.StartCommand("CATAfrCylindricViewHdr")
rickyt macro is working also but I noticed you need to click again somewhere after clicking in the message box to see the change.
If you don't like macros, I would use what MarkAF proposed, which is a very handy solution for the most common commands you usually use.

Regards
Fernando

 
V5 has the 3dconnexion space mouse toolbar called "3dx Device" which got me, if you wanted it for 3dexperience.

Ferdo,
I noticed the same thing, that the view rendering type does change immediately on the screen.
But If I go to check Rendering Style, it still shows the previous mode until another command is activated.
I tried a few things to make it update, but couldn't find a solution.

As image below shows rectangular block in Perspective mode, but Catia indicates Parallel until another command is activated.
220924_Image001_dlaagi.jpg
 
Thanks everyone,

Sorry for the confusion with 3Dx. I'm using Catia V5. 3Dx is the catia name for spacemouse.

rickyt your code works wonders. I switches instantly. I just deleted the msgbox lines because I want to reduce my clicks with macros :)

About that updating thing, as long as it's not causing trouble I wouldn't bother with it. I think when you run the macro then select a surface or a part in the tree it updates. But it's hard to define which triggers the update.
 
Status
Not open for further replies.
Back
Top