I’m trying to build a little macro for a button that creates a viewport with the size I write into this macro.
I need to indicate the size as a fraction. This works if the result of the fraction is an integer value (in this case 400) but it doesn’t work if the denominator is a number that produces a non-integer value (for example, if I put 3 in the denominator the macro doesn’t work).
1- is there a way to avoid this?
2- I often need to change the denominator so… is there a way to put the number of the denominator in a window without opening the macro’s button?
This is the work in progress macro: thank you in advanced
! _NewFloatingViewport
_Projection _Perspective
_-viewportproperties
s
800/2
800/2
!
Hi,
as explained in my first post, I often need to change the denominator so it would be very useful to insert this value on the command line. I tried to understand how to to it in the script but I’m not able…can you help me?
_-NoEcho -RunScript (
A = Rhino.GetReal(“Insert percentage”, 50, 10)
If Not IsNull(A) Then
w = CStr(CInt(100 * A / 100))
h = CStr(CInt(100 *A / 100))
Call Rhino.Command("-NewFloatingViewport _Projection Perspective", 0)
Call Rhino.Command("-ViewportProperties _Size " & w & " " & h & " _Enter", 0)
End If
)
I can’t code this:
if w or h is < 20 then print on command line: “the frame is too smal: please, increase the percentage”. Do the script again
Can you help me?
Option Explicit
Call Main()
Sub Main()
Dim a,w,h,msg
'initial message
msg = "Insert percentage"
'create a loop to repeat process indefinitely
Do
A = Rhino.GetReal(msg, 50, 10)
'exit script is A is not entered
If Not IsNumeric(A) Then Exit Sub
w = CStr(CInt(100 * A / 100))
h = CStr(CInt(100 * A / 100))
'check values and exit the loop if they are acceptable
If w >= 20 And h >= 20 Then Exit Do
'if not, change message and go back to the beginning of loop
msg = "Frame is too small, please increase the percentage"
Loop
'execute command onec data is OK
Call Rhino.Command("-_NewFloatingViewport _Projection Perspective", 0)
Call Rhino.Command("-_ViewportProperties _Size " & w & " " & h & " _Enter", 0)
End Sub
Hi Helvetosaur and thanks for your script.
I put this script on the button with " _-NoEcho -RunScript (" on the beginning and !)! on the end but seems not to work