Skip to content

Instantly share code, notes, and snippets.

@jimfoltz
Last active October 10, 2015 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimfoltz/8d19ef1be1f22bc8e99e to your computer and use it in GitHub Desktop.
Save jimfoltz/8d19ef1be1f22bc8e99e to your computer and use it in GitHub Desktop.
detect-dc.rb
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