as a jeweller I often use " orient on surface" tool to place stones on surfaces. when I use orient on surface I hit the coordinate “0” in the Top viewport and then choose the surface I want to place. so instead of typing 0 and enter in top viewport I wrote a little macro script like this.
! _OrientOnSrf pause SetActiveViewport top 0 0,5,0
it works fine but the trouble is when it’s in perspective viewport which is expanded in full viewport it switches to top viewport so I have to minimize the top viewport and go back to the perspective viewport.
can you change that macro script to other type of the script so that when it is in perspective viewport it doesn’t switch to top viewport??
can you also change this one as well??
! _ArrayCrvOnSrf pause SetActiveViewport top 0
Many thanks
that doesn’t work if I do it in the front viewport as you see the picture below. the stones place in wrong way.
also how would you change it to the python or vb script?? is it possible??
I see. OrientOnSrf require an initial orientation plane. And this plane is being taken from the Top view. So, it is important that your macro always start from the Top view.
A RhinoScript script might be helpful. Here is one you can start with:
Sub MyOrientOnSrf
' Declare local variables
Dim arrObjects, strObject
Dim strView, blnMaximized
Dim strCmd
' Select objects to orient
arrObjects = Rhino.GetObjects("Select objects to orient",, True, True)
If IsNull(arrObjects) Then Exit Sub
' If the current view is maximized, restore it
strView = Rhino.CurrentView
blnMaximized = Rhino.IsViewMaximized(strView)
If (blnMaximized) Then
Call Rhino.MaximizeRestoreView(strView)
End If
' Set the the active viewport to the "Top" viewport
Call Rhino.Command("SetActiveViewport Top")
' Build a command macro string
strCmd = "OrientOnSrf"
For Each strObject In arrObjects
strCmd = strCmd & " SelId " & strObject
Next
strCmd = strCmd & " Enter 0 0,5,0"
' Run the OrientOnSrf command macro
Call Rhino.Command(strCmd)
' If the current view was maximized, restore it
If (blnMaximized) Then
Call Rhino.MaximizeRestoreView(strView)
End If
' Done!
End Sub
Hi Dale
thanks for your help. I tried to make a button for it but it doesn’t work.here’s script
-_Runscript(
Sub MyOrientOnSrf
' Declare local variables
Dim arrObjects, strObject
Dim strView, blnMaximized
Dim strCmd
' Select objects to orient
arrObjects = Rhino.GetObjects("Select objects to orient",, True, True)
If IsNull(arrObjects) Then Exit Sub
' If the current view is maximized, restore it
strView = Rhino.CurrentView
blnMaximized = Rhino.IsViewMaximized(strView)
If (blnMaximized) Then
Call Rhino.MaximizeRestoreView(strView)
End If
' Set the the active viewport to the "Top" viewport
Call Rhino.Command("SetActiveViewport Top")
' Build a command macro string
strCmd = "OrientOnSrf"
For Each strObject In arrObjects
strCmd = strCmd & " SelId " & strObject
Next
strCmd = strCmd & " Enter 0 0,5,0"
' Run the OrientOnSrf command macro
Call Rhino.Command(strCmd)
' If the current view was maximized, restore it
If (blnMaximized) Then
Call Rhino.MaximizeRestoreView(strView)
End If
' Done!
End Sub