Select details


#1

Good mornings creative script people,

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?

Thank you.

Cosmas


#2

I have a way to do this now - but the question is, what do you want to do if some details are locked and some aren’t?

–Mitch

The example below will lock all details if all details on the same page are found unlocked.

If at least one is locked, it will unlock them all…

You need to have a detail view active for this to work. Obviously not currently going to work on Mac.

This can be modulated differently… let me know.

Thanks to @menno for the help…

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()

#3

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).

A second script would do the opposite.

I would then attach each one to an alias.

Is this doable?

Thank you.


#4

Sure, that’s even easier…

Lock:

"""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()

–Mitch


#5

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.

Thank you.

Cosmas


#6

Hi Cosmas,

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.

–Mitch


#7

I didn’t realize it was a python script.

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.

Thank you very much.

Cosmas


#8

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…

–Mitch

DetailLock.rhp (8.5 KB)


#9

Thank you, Mitch. I really appreciate it.


#10

@Mitch,

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 advanceDetailLock%20Error%20message

Cosmas


#11

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.

–Mitch


#12

Interesting, Mitch. I’ll run it by Pascal and see if he can figure it out. Thank you:)