This one should be simple but I’m having trouble coming up with the right commands. If I want a macro that selects all the details on a layout page and toggles the lock/ unlock, what would it be?
import scriptcontext as sc
def ToggleDetailLock():
#need a layout page active
if not sc.doc.Views.ModelSpaceIsActive:
layout_page=sc.doc.Views.ActiveView
details=layout_page.GetDetailViews()
checksum=0
for det in details:
checksum+=det.Geometry.IsProjectionLocked
if checksum==0:
#all details are unlocked, lock them all
for det in details:
det.Geometry.IsProjectionLocked = True
det.CommitChanges()
else:
#at least one detail is locked, unlock all
for det in details:
det.Geometry.IsProjectionLocked = False
det.CommitChanges()
else:
print "Active view is not a layout view!"
ToggleDetailLock()
Thank you, @Mitch. I really appreciate your help (and @menno). Maybe instead of toggling lock / unlock, we should have two scripts:
One locks all the details on a page (regardless of whether, some are locked and some are unlocked, and if it finds that all are already locked it would leave them locked).
"""Locks all details on a layout page (page must be active)
Script by Mitch Heynick 12.02.15"""
import scriptcontext as sc
def LockAllPageDetails():
#need a layout page active
if not sc.doc.Views.ModelSpaceIsActive:
layout_page=sc.doc.Views.ActiveView
details=layout_page.GetDetailViews()
for det in details:
if not det.Geometry.IsProjectionLocked:
det.Geometry.IsProjectionLocked = True
det.CommitChanges()
else:
print "Active view is not a layout view!"
LockAllPageDetails()
Unlock:
"""Unlocks all details on a layout page (page must be active)
Script by Mitch Heynick 12.02.15"""
import scriptcontext as sc
def UnLockAllPageDetails():
#need a layout page active
if not sc.doc.Views.ModelSpaceIsActive:
layout_page=sc.doc.Views.ActiveView
details=layout_page.GetDetailViews()
for det in details:
if det.Geometry.IsProjectionLocked:
det.Geometry.IsProjectionLocked = False
det.CommitChanges()
else:
print "Active view is not a layout view!"
UnLockAllPageDetails()
Hey @Mitch
Sorry to be so dense but there is something I must be missing. I pasted the first one in to scripteditor and saved it as an rvb called locksaslldetails.rvb. I then dragged and dropped it in to Rhino but got a Microsoft VBScript compilation error message (Undeterminated string constant). When I look at other scripts they seem to start with OptionExplicit and have Sub and End Sub… language that doesn’t seem to be a part of the code you gave me.
My goal is to set an alias for each one of these, not make a button.
I really appreciate your “spoon-feeding” me through this. I will save your instructions for future scripts.
These are Python scripts, not VB scripts. You can’t actually do this in vb Rhinoscript.
They are not set up for drag and drop. (you can’t with Python right now). In order to add commands, I will need to put them into a plug-in - I have meetings right now, I’ll have to do that later. Otherwise, if you have a scripts folder somewhere where you store stuff, I can manually walk you through how to set up your alias.
Very proud of myself. I dug up Djordje’s instructions for a python script that he made for me a few months ago, and used them on yours. Both scripts work perfectly.
OK, too late back here - here is a drag and drop plug-in version (hope it works). It adds two commands:
LockAllPageDetails UnlockAllPageDetails
The reason I don’t like to put out plug-ins is that they are not directly editable, and for small stuff, too much work. The other thing I worry about is name conflicts…
I need some Mitch help from you. My beloved DetailLock plug-in that you made for me seems to have stopped working. The wierd thing is that it was working until yesterday and I have been using v6 for months now. When I run it I sometimes get an error message (see screen grab attached) and sometimes I don’t. But it always calls it an “Unknown command” in the command line, even though when I look on the Plug-Ins tab it is clearly loaded and is pointing to the folder where it is stored. I really would appreciate some Mitch help with it:) Thank you, in advance
This is why I don’t do plug-ins… I have no idea what might be failing, if some new update to V6 has broken stuff or what… I think you have the only plug-in I ever did, after that I gave up as it was far too much hassle to create them.
The individual scripts run from the script editor run fine here in the current 6.3 RC…
Someone else may be able to tell you why the plug-in stopped working, but not me, unfortunately.