Last active
October 10, 2015 11:58
-
-
Save jimfoltz/8d19ef1be1f22bc8e99e to your computer and use it in GitHub Desktop.
detect-dc.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module JF | |
module DetectDC | |
DICT = "dynamic_attributes" | |
class AppObserver < Sketchup::AppObserver | |
def expectsStartupModelNotifications() | |
return true | |
end | |
def onOpenModel(model) | |
JF::DetectDC.detect(model) | |
end | |
end # class | |
def self.detect(model) | |
if is_dc?(model) | |
show_message() | |
end | |
end | |
def self.is_dc?(model) | |
dict = model.attribute_dictionary(DICT) | |
return !dict.nil? | |
end | |
def self.show_message | |
msg = "Notice!\n\nThe file you have opened may be a Dynamic Component intended to be imported." | |
UI.messagebox(msg) | |
end | |
def self.main | |
Sketchup.add_observer(JF::DetectDC::AppObserver.new) | |
end | |
end | |
end | |
JF::DetectDC.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment