sketchucation logo sketchucation
    • Login
    1. Home
    2. jessejames
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    โš ๏ธ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
    J
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 166
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Major problems viewing SCF in IE8

      @jackson said:

      That said, I guess I should give Chrome a try.

      If you like a minimalist approach you'll love chrome!

      @unknownuser said:

      It just a browser and a browser it's just.

      Although they released chrome b2 with extension capabilities just like FF (of which a nice repository is building!) So i think chrome my be eventually the next replacement for FF. (and of course IE but thats a no brainer ๐Ÿ˜„ )

      posted in Corner Bar
      J
      jessejames
    • RE: Why the dutch are mad

      @unknownuser said:

      WHY THE DUTCH ARE MAD

      hmm, could it be those wooden clogs? Seems they'd be about as comfortable as a wedgie ๐Ÿ˜ฒ

      posted in Corner Bar
      J
      jessejames
    • RE: Find the global position of a Vertex in a Group/Component

      @thomthom said:

      SU changes the co-ordiates when you open a group/component. When a group or component is open SU returns global co-ordinates for the entities in that context.

      It seems Tim Toady is more prevalent that i had originally feared! ๐Ÿ˜ฎ

      PS: Before some hot shot notices i made a mistake in accessing the origin using

      collection..transformation[-1]
      

      Since the transformation is a 16 element array an NOT a 4 element array of 4 element sub arrays that code will only return the last float.

      posted in Developers' Forum
      J
      jessejames
    • RE: Find the global position of a Vertex in a Group/Component

      @gbabcock said:

      Being new to this, I've been searching around to find a way to get the global position of a vertex when it is in an unopened group, or even worse when it is in a nested group.

      Lets make this simpler and use the term "collection" to refer to both groups and components. There is no difference in finding the "world coordinate" of a vertex contained in a collection whether or not the "collection" is "open" or "closed". If it's nested yes, but only a minor difference in the form of recursion.

      @gbabcock said:

      I found a lot of good info in this forum, and learned that you need the Point3d of the vertex AND the Transformations of the parent Group(s) and/or Component(s). The problem is how to get the parents starting from an edge without walking the entire Group/Component/Model from the top-down.

      You specifically need the "collections" origin which is a point and the point you wish to find. You see whenever a "collection" is created the origin of that "Collection" is equal to the minX, mixY and minZ "parent coordinates" of the bounding box of that collection. You can easily query this origin at any time by using...

      Tim Toady's first method

      collection.transformation.origin
      

      Tim Toady's second method

      collection.transformation.to_a[-1]
      

      ...since a transformation is just a four element array containing the [[Xaxis], [Yaxis], [Zaxis], [origin]] sub arrays.

      @gbabcock said:

      The SU API seems to be very top-down oriented, and it is not intuitive how you walk up the hierarchy. Assuming that this is correct?:

      HIERARCHY
      === Model
      ====== DefinitionList
      ========= ComponentDefinitions
      ============ ComponentInstances #collection of Group or Components Instances
      ============ Entities
      ============ ComponentDefinitions
      =============== ComponentInstances #collection of Group or Components Instances
      =============== Entities

      No thats completely wrong. The definition list is an attribute of MODEL just like ENTITIES is an attribute. If you where to map out a simplistic version of the API it might look like this...

      [warning: loose code ahead!]

      
      class Model(collection)
        self.definitionList = {def1, def2, ..., defN}
        self.entities = {ent1, ent2, ..., entN} # infinite nesting here!
        # lots more stuff here...
      end
      
      class Group
        self.entities = {ent1, ent2, ..., entN} # infinite nesting here!
        # more stuff
      end
      
      class ComponentInstance
        self.entities = {ent1, ent2, ..., entN} # infinite nesting here!
        # more stuff
      end
      
      model = Model()
      model.entites.push(Group())
      model.entites.push(....)
      ....
      
      

      (of course at the C level it's much different!) Model is just a top level "collection" like groups or components. You add all edges, faces, groups, components to the Model entities. and then you can nest infinitely (or until you run out of memory!) the collections in model.entities

      (I'll probably be lambasted for making such a simplistic model ๐Ÿ˜•, oh well!

      Anyhow just remember a vertex inside a collection has a position relative to the collections origin. So as an example... if vertexA is an entity contained in groupA which is a collection contained in the model.entities array then...

      @unknownuser said:

      if vertexA is at [0,0,1] and groupA's origin at [0,0,1] then the world space coordinates of vertexA will be at [0,0,2]

      PS There may be those of you who are wondering who Tim Toady is. Tim Toady is a pronunciation of the acronym TMTOWTDI (or TIMTOWTDI). Basically it describes a paradigm you new Ruby scripters will need to get acquainted with ...More info can be found here.

      PPS hopefully i have managed to shed some light on your dilemma and not simply confused you even more. I would like to go into more details at this time but "crikey" i need some sleep!

      posted in Developers' Forum
      J
      jessejames
    • RE: Major problems viewing SCF in IE8

      @jackson said:

      In short SCF has become almost impossible for me to view in IE8

      Then why in the world would you continue to use Internet Exploder? I have dropped IE ever since Google Chrome was released and i haven't look back since. Mys browsing is faster, safer (at least for the time being??) and i also get that cool feeling in my tummy knowing that i am "sticking it" to Microsoft! ๐Ÿ‘ฟ

      Not only that i save megabytes of monthly updates/patches/hot-fixes that i would need with the horrible IE! No thanks M$!

      I have tried to use Firefox in the past but am turned off by it's failure to trim unnecessary bloat! So in my world Chrome is numero uno!

      posted in Corner Bar
      J
      jessejames
    • RE: A chuckle...

      Good one. For those of you who don't get it...

      The boy thought the rancher wanted to hire Howard to impregnate his daughter, good laugh!

      posted in Corner Bar
      J
      jessejames
    • RE: Ruby namespace?

      @dan rathbun said:

      (7) The methods within the 'sketchup.rb' script were intended (for the most part,) to extend developer's use of the classes Module and Class. BUT they were not wrapped within the proper namespace(s) in the script, and so get defined as methods of Object, and so become inherited by ALL classes, such as the Numeric classes, the Sketchup::Entity subclasses, the Geom::subclasses, etc. where they will NEVER be used.

      Very informative post Dan! But i disagree that the problem boils down to a lowly script. This problem is inherent in the design of the Ruby language itself!

      @dan rathbun said:

      Open a new model, draw something simple a cube, select a Sketchup::Face object. Switch to the console, type (all 1 command):
      **Sketchup.active_model.selection[0].private_methods(true).sort.join("\n")**
      Look at the list, you will see that the Face object has inherited as private methods (which you will never call from outside the object,) all those methods defined in 'sketchup.rb'!
      What kind of drain of memory will this have when you get to a model that has tens of thousands of Entities it it?

      Exactly! this is what most of the folks in this thread have missed! Ruby just blindly sucks in every method it can find! In Python we have a system of using single and double leading underscores to indicate private and public methods. It's not a forced convention but we all understand and use it like a forced convention.

      But even more importantly Python objects have a dir "special method" that will return the appropriate list of methods when using the introspection function dir(obj). Python also (as i have mentioned time and time again) uses every file as "module" automatically so none of the name clashing occurs unless you import the module in a certain manner.

      posted in Developers' Forum
      J
      jessejames
    • RE: FBI wants records kept of Web sites visited

      For those of us on the "inside" (the enlightened few) we know that the government has been monitoring our thoughts using cell towers as mind reading and mind control devices for years! This whole Goole+NSA mumbo-jumbo is just another cover story to keep our attention focused on the wrong thing!

      I highly suggest everyone that has read (or will read this thread in the future) to learn how to make a homemade "Faraday Cage" (AKA: Tin Foil Hat) before you lose all ability to make your own decisions and become a drooling mindless zombie in perpetual pursuit of more government Koolaid! The life you save may very well be your own!

      Now before some of the naysayers start their "nay saying" i have found a Wiki article that proves SCIENTIFICALLY (and far beyond any reasonable doubt) that these "tin foil hats" do in fact protect the brain from the meddling rays of governments world-wide!
      http://en.wikipedia.org/wiki/Tin_foil_hat

      ######################################

      Potential Agents we've uncovered

      ######################################
      The NSA and CIA have covert agents looking for us at all times. Here are a few desquises we have uncovered

      Wal-Mart Greeters
      Agents have infiltrated the ranks of walmart greeters and have been very successful at taking down our strongest foil mules. And since walmart provides us with such large volumes of foil we are poised to fight our fearist battles there. Don't let their age fool you, these "greeter agents" are very cunning and always alert! And never, ever engage one in direct conversation because they will force information from you with their "geriatric" mind tricks!

      Little Old Ladies Crossing The Street
      This is by far their most sneaky attack by using our kindness against us! Although lacking the cunning and Jedi prowess of walmart greeters these "vertically challenged agents" use their unique "angle of perspective" to spot tin foil hats even when carefully covered by 10 gallon cowboy hats and novelty sombreos. Resist your temptations to be kind!

      Pizza Delivery People
      No matter how hungry you get creating tin foil hats never ever order a pizza to be delivered because i guarantee you an agent will be knocking at your door in 30 minutes or less! But if your hunger gets the best of you just be damn sure NOT to eat the parmasian cheese! Its really "pixie dust" that will render the tin foil hat useless for up to three days!

      ##########################

      Tips for buying foil

      ##########################
      Always keep spare foil in your pantry. When buying the foil never buy only foil, they will spot you a mile away. Also if you see a "normal" looking employee casually "tidying up" the foils on isle 13 wait until they leave before approaching the foil! And if anyone ever asks why you need the foil always tell them you are having a back yard bar-b-que!

      posted in Corner Bar
      J
      jessejames
    • RE: Tool Needed

      Probably the best place to start is "linetool.rb" since it comes with the distribution. Or any other tool script out there that fits the discription better.

      PS "Just make sure its OSS so you don't break any Texas laws!! I think they still hang people down there!"

      posted in Developers' Forum
      J
      jessejames
    • RE: Creating a bounding face around an instance

      Tig's methods sounds correct but he missed the point that the "user" will be placing this window first and then running the script. There may be a simpler solution to this problem...

      For me an ideal situation would be to tag the points that will rest on the "wall face". Then its just a matter of saying to the component HEY!, where are pt1, pt2, pt3, and pt4, located right now? this will make the job so much more easier.

      So the much more simplified outline would be as follows

      First what are the facts we can query at runtime of the script...?

      1. the face upon which this componet will be cutting (CI.glued_to?)
      2. the four corners within the component that will touch "this" face

      With these two simple facts all one needs to do is create a loop on the face using the four points (or do an intersect of component and face and then search for the appropriate "hole loop") and voila! You know what to do next

      Of course it's easy to outline a problem but i think my logic is sound, let me know if there are any holes here...?

      posted in Developers' Forum
      J
      jessejames
    • RE: Ruby Console hell... no more!

      @unknownuser said:

      Would now be a bad time to point out i actually quite enjoy scripting in SU?

      Great punch line remus ๐Ÿ˜‰. Your keen sense of comic relief no doubt qualifies you as a mod. I always seem to get a good giggle from your posts.

      But seriously folks we have an issue here. Some people will say that tring to improve SketchUp is a lost cause. Well that may be slightly true but we cannot give up already. I think a lot of newer scripters (some may never had experianced with scriping before) are now joining the fray but have found major workflow issues that quite frankly are just impossible to overcome alone...

      @unknownuser said:

      Wait a minute Jesse!

      uhhh, excuse me a moment, Yes Joe!

      @unknownuser said:

      Jesse, why in the world would some people feel that SketchUp scripting (the way it stands now) is a good system? We all know it sucks eggs!

      Thats a good question Joe and one has many complicated and reveiling answers. You ever hear the expression "more than meets the eye" Joe? I think for one people just get so accostomed to something that the "fear of change" simply (in their minds) out-weighs the hassles they currently endure. So they just choose to endure it.

      What about the "Helsinki Syndrome", have you ever heard of that one Joe? Well some correlations can be drawn between that state of mind and the current state of SketchUp scripters. If you where to ask them privately you'll find that they are just scared Joe, they feel helpless, and like little children they need guidance to free their minds from this hell-state.

      For example, lots of people use Microsoft OS even when far better (and free) choices are available. But what is most entertaining is when you ask them WHY? Why do you choose to use a proprietary OS when a number of free alternatives exists? It's like a deer caught in headlights Joe, don't even waste your time.

      But sadly there is also evil afoot in the form of FUD mongers and jolly green greedies. Some people have capital gains to be made from SketchUp scripting and they will do anything to keep their piece of the pie even if that means stepping on the little people (thats you and me Joe) to get to where they are going. Sometimes just by making a system uncomfortable you can keep the noobies out and therefore curtail competition. This system has been successfully employed by many major corporations! But we are not here to talk about M$'s evil world domination practices, we are here for the wonderful SketchUp.

      @unknownuser said:

      This is all very sad Jesse ๐Ÿ˜ž, i'm beginning to lose faith in my fellow SketchUp brothers and sisters.

      Yes i know, but i believe in growth Joe, and i believe in change. i believe we can cultivate these confused chaps into productive scripters that produce SketchUp scripts with much ease. No more shall they lament the torturous trappings of the Ruby Console. No more shall they endure 3rd party patch-ware and windowing multiplicity! Heck, they may even start to enjoy this!

      posted in Developers' Forum
      J
      jessejames
    • RE: Ruby Console hell... no more!

      @thomthom said:

      One thing I noticed about the webdialog - you still needed the Console open to see error messages and puts statements. Would this multi-line console avoid that?

      Very True, you bring up a very good point thomthom!! Your insights no doubt qualify you as moderator material. No matter how great any Ruby console "we" make is... it shall always and forever suffer the plague of the blacksheep, the outsider, and the village idiot. It will never integrate fully with the SketchUp application. This is what makes any argument for the current console completely and utterly untenable!

      Face it guy's scripting SketchUp is painful because of this self imposed bottleneck. We have to be rodeo level window herders to manage this herd of RubyConsoleWindow, SketchUpWindow, SomeThirdPartyIDEWindow, SomeThirdPartyConsoleWindow, and don't forget to check the RubyConsole for stdout and stderrr or don't forget to issue a "load this.rb" command to reload your scripts after every modification.... what a nightmare for pros and a torture chamber for noobs!

      Sadly so many of us have taken the "if you can't beat'em, join'em" approach or simply just cannot stomach a fight to fix this problem. Well people it's time to get off your keysters' and join the march!

      Only we can fix this. That "WE" is you and me. Even if that means writing the damn code and emailing it to some SU Dev honcho with a "Copy and paste this or else!" letter attached. I guarantee you if we do a little work our selfs and yell loud enough we can do this!

      ...are you with me?

      posted in Developers' Forum
      J
      jessejames
    • RE: Ruby Console hell... no more!

      @chris fullmer said:

      I have not checked it out yet but fully plan on it. Great Job Jesse on getting something posted.

      @Chris!
      You always make me feel very welcome here and that is the kind of people that really deserve to be mods and admins... Thanks! And yes, i had written this script a very long time ago and completely forgot about it until Alex posted his improved web console a few days back. Like thomthom noted Alex's webconsole has multi line capabilities and looks very nice. But some SketchUp folks may wonder...

      @unknownuser said:

      Jesse, why bother to post your multi-line console when it seems that Alex has cornered the market? Is this really a "microcosm" of SketchUp scripting industrial espionage?

      Not exactly Joe, i think Alex and i are on the same page but simultainously we are two sides of the same majestic mountain! The major difference between my goals and Alex's goals is that i believe a multi-line console is so important that i very much intend to get a fully functioning (GUI based) multi-line console built-in to SketchUp herself!

      Like our good friend thomthom has pointed out, there are many great scripts and IDEs out in the wild. HOWEVER none are built into Sketchup!

      @unknownuser said:

      So Jesse what you are saying is that currently a scripter' not only has to download a 3rd party console but that any third party console will never be as useful as a built in console...?

      No Joe, thats exactly what i am saying!! You see, i have worked with many applications UI's and scripting inputs and i can tell you one thing -- NOTHING is more important to a noobie or professional than the ability to test code snipit's "interactively" in an "intuitive" environment with a GUI based tool that does not force you to swim in the lake of archaic asinine redundancies.

      @unknownuser said:

      Ok Jesse you put the hook in me and i'm ready to buy the extended warranty, but where do we go from here?

      Well Joe a good start would be to get the word out. Show these SketchUp scripters that there is an better way and they have the power to make this a reality. We have a bunch of really smart folks here but they are just lost at sea. We just need to fire up the old light house and show the way home... We can give them hope, but only they can bring about real change.

      posted in Developers' Forum
      J
      jessejames
    • Ruby Console hell... no more!

      Hello all. I am not sure if this post should be under "Plugins" or "developers" but i feel the groundbreaking and enlighting power of the following code better serves a developers eyes!

      Ok folks, as you all know i vehemently despise the ruby console (and some other things) so i now intend to put my money where my mouth is -- so to speak! My personal belief is that the Ruby console in SketchUp is completely usless. But at the same time i realize that the SU dev team cannot spend any valuable time making the console better, but i can! I have created a template of sorts for you guys to build from in the form of a Python Tkinter (thats TCL/Tk for those who know) multi-line simplistic Ruby console.

      @unknownuser said:

      "Why is the Ruby Console so useless JesseJames?"

      Thats a good question my inquisitive friend!

      Well for starters it confines you to a 'one-line-at-a-time' input. This is very frustrating and renders the console completely useless. I intend to change that and i have included source code! To run this code you will need the awesome Python programming language (Google it!).

      My hope is that some fellow Ruby scripter will take this code and write it up with Ruby+Tk or Ruby+wx or whatever. However if one or of you are interested i may be able to make this work with Supy, just let me know...?

      The script is just the most basic of multi-line consoles. I could eaisly add...
      *Auto Complete
      *Auto Indent/Dedent
      *Syntax highlight
      *your wish here

      The software was created for to reasons...
      -To show how easy it is to build GUI applications with Tkinter and Python
      -To try and persuade the Sketchup dev team to create a better Ruby Console using this script as a template and release it with SketchUp.

      But if we could just get this simple muti-line console into Sketchup it would be one thousand times better than the current situation. So now the ball is in your court Ruby masters. I have done the all dirty work. You can help me send the current Ruby console to the Google trash heap where it belongs, enjoy!

      
      # ---------------------------------------------------------------------------------
      # Copyright 2010 jessejames
      #
      # Permission to use, copy, modify, and distribute this software for 
      # any purpose and without fee is hereby granted, provided that the above
      # copyright notice appear in all copies.
      #
      # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
      # ----------------------------------------------------------------------------------
      #
      # This software was created for to reasons...
      # -To show how easy it is to build GUI applications with Tkinter and Python
      # -To try and persuade the Sketchup dev team to create a better Ruby Console
      #   using this script as a template and release it with SketchUp. 
      #
      # My personal belief is that the Ruby console in SketchUp is completely usless.
      # But at the same time i realize that the SU dev team cannot spend any valuable time
      # making the console better, but i can! You may ask... "Why is the Ruby Console so
      # usless JesseJames?" Well for starters it confines you to a 'one-line-at-a-time'
      # input. This is very frustrating and renders the console usless. I intend to change
      # that and here is my simple solution. To run this code you will need the Python
      # programming languge (Google it!). My hope is that some fellow Ruby scripter will
      # take this code and write it up with Ruby+Tk or Ruby+wx or whatever. However if one or
      # of you are interested i can make this work with Supy, just let me know...?
      #
      # This script is just the most basic of multi-line consoles. I could eaisly add...
      #    *Auto Complete
      #    *Auto Indent/Dedent
      #    *Syntax highlight
      #    *your wish here
      #
      # But if we could just get this simple muti-line console into Sketchup it would be
      # one thousand times better than the current situation. Enjoy ;)
      
      
      import sys, traceback
      import Tkinter as tk
      from tkMessageBox import showinfo
      
      __all__ = ['Cmd']
      
      INSERT = 'insert'
      END = 'end'
      SEL = 'sel'
      SEL_FIRST = 'sel.first'
      SEL_LAST = 'sel.last'
      
      def _showsyntaxerror(self, filename=None);
          # taken form IDLE
          type, value, sys.last_traceback = sys.exc_info()
          sys.last_type = type
          sys.last_value = value
          if filename and type is SyntaxError;
              # Work hard to stuff the correct filename in the exception
              try;
                  msg, (dummy_filename, lineno, offset, line) = value
              except;
                  # Not the format we expect; leave it alone
                  pass
              else;
                  # Stuff in the right filename
                  value = SyntaxError(msg, (filename, lineno, offset, line))
                  sys.last_value = value
          list = traceback.format_exception_only(type, value)
          return ''.join(list)
      
      def _showtraceback(self);
          # taken from IDLE
          try;
              type, value, tb = sys.exc_info()
              sys.last_type = type
              sys.last_value = value
              sys.last_traceback = tb
              tblist = traceback.extract_tb(tb)
              del tblist[;1]
              list = traceback.format_list(tblist)
              if list;
                  list.insert(0, "Traceback (most recent call last);\n")
              list[len(list);] = traceback.format_exception_only(type, value)
          finally;
              tblist = tb = None
          return ''.join(list)
      
      def _selectchars(text, chars='>>> ', back=False, forw=False);
          if back;
              start = text.index('insert linestart')
              stop = '1.0'
          elif forw;
              start = text.index(INSERT)
              stop = text.index(END)
          else;
              raise Exception('I cant search forwards *and* backwards you nitwit!')
          idx = text.search(chars, start, backwards=back, forwards=forw, stopindex=stop)
          if idx;
              text.mark_set(INSERT, text.index(idx+' + 4 c'))
              text.tag_remove('sel', '1.0', END)
              text.tag_add('sel', 'insert', 'insert lineend')
              text.see(INSERT)
      
      def _getwhite(s);
          # yes i know in-place concat of a string is slow
          # but for this it'll do just fine, trust me! And yes
          # i could use an regexp but i'm writing this code TYVM! ;)
          S = ''
          for x in s;
              if x == ' ';
                  S += ' '
              else;
                  return S
          
      
      class _ScrolledText(tk.Text);
          def __init__(self, master, **kw);
              self.frame = tk.Frame(master)
              self.frame.rowconfigure(0, weight=1)
              self.frame.columnconfigure(0, weight=1)
              kw.setdefault('undo', 1)
              kw.setdefault('autoseparators', 1)
              kw.setdefault('highlightthickness', 1)      
              self.vbar = tk.Scrollbar(self.frame, orient='vertical')
              tk.Text.__init__(self, self.frame, **kw)
              self.grid(row=0, column=0, sticky='nswe')
              self.vbar.configure(command=self.yview)
              self.config(yscrollcommand=self.vbar.set)
              self.vbar.grid(row=0, column=1, sticky='ns')
              self.grid = lambda **kw; self.frame.grid(**kw)
          def gets(self);
              return self.get(1.0, END)
          def sets(self, arg);
              self.delete(1.0, END)
              self.insert(END, arg)
              self.mark_set(INSERT, '1.0')
              self.see(INSERT)
      
      
      class Cmd(tk.Toplevel);
          def __init__(self, master, glo, loc, widget=None, **kw);
              self.glo = glo
              self.loc = loc
              self.glo['commandprompt'] = self
              self.startidx = '1.4'
              self.v = tk.StringVar()
              self.pixels = None
              self.buffer = ''
              self.saveHeight = None
              tk.Toplevel.__init__(self, master)
              self.columnconfigure(0, weight=1)
              self.rowconfigure(0, weight=1)
              #self.attributes('-topmost', True)
              self.attributes('-toolwindow', True)
              self.transient(master)
              self.lift(master)
              self.title('Command Prompt')        
              self.protocol("WM_DELETE_WINDOW", self.onQuit)
              #-- Widgets --# 
              kw.setdefault('width',60)
              kw.setdefault('height',10)
              kw.setdefault('font',('Courier New',10))
              kw.setdefault('wrap','word')
              self.text = _ScrolledText(self, **kw)
              self.text.grid(row=0, column=0, sticky='nswe')
              #-- Bindings --#
              # Kill some default bindings that we don't need.
              for seq in ('Delete','Button-2','Button-3','B2-Motion',
                          'B3-Motion','ButtonRelease-2','ButtonRelease-3',);
                  self.text.bind("<%s>"%(seq), lambda e; "break")
              self.text.bind("<KeyPress>", self.onKeyPress)
              # Had to bind control-up and control-down directly because
              # the value for "event.state" keeps changing! ;-?
              self.text.bind("<Control-Up>", self.onControlUp)
              self.text.bind("<Control-Down>", self.onControlDown)
              #-- Setup --# 
              self.text.insert('end', '>>> ')
              self.focus_set()
              self.text.focus_set()
      
          def onQuit(self);
              self.grab_release()
              if self.master;
                  self.master.focus_set()
              self.destroy()
      
          def command_hook(self);
              # override me please. ;)
              print 'Cmd.command_hook()'
      
          def write(self, arg);
              self.buffer+=arg
      
          def flush(self);
              if self.buffer;
                  self.out('out', 'blue', '\n'+self.buffer)
                  self.buffer = ''
      
          def out(self, name, color, textstr);
              text = self.text
              start = text.index('end')
              text.insert('end', '\n%s' %(textstr))
              end = text.index('end - 1 c')
              text.tag_add(name, start, end)
              text.tag_configure(name, foreground=color, font=('Courier', 8))
      
          def execute(self, cmd);
              #XXX need support for sys.exit here!
              if 'print' in cmd;
                  # `commandprompt` variable was injected in contructor
                  cmd = cmd.replace('print', 'print>>commandprompt, ')
                  print cmd
              try;
                  e = str(eval(cmd, self.glo, self.loc))
                  self.out('out', 'blue', e)
                  self.command_hook()
              except Exception;
                  try;
                      exec(cmd, self.glo, self.loc)
                      self.flush()
                      self.command_hook()
                  except SyntaxError;
                      self.out('err', 'red', _showsyntaxerror(None))
                  except Exception;
                      self.out('err', 'red', _showtraceback(None))
      
          def onControlUp(self, event);
              #print 'onControlUp'
              _selectchars(self.text, back=True)
              return "break"
          
          def onControlDown(self, event);
              #print 'onControlDown'
              _selectchars(self.text, forw=True)
              return "break"
      
          def onKeyPress(self, event);
              text = self.text
              outOfZone = text.compare(text.index(INSERT), '<', self.startidx)
              key = event.keysym
              if key.lower() in 'c' and event.state == 12;
                  # let copy action thru
                  pass
              elif key == 'F12';
                  self.onF12()
                  self.text.edit_reset()        
              elif key in ('Up', 'Down', 'Left', 'Right', 'Home', 'End');
                  pass
              elif outOfZone;
                  if key == 'Return';
                      text.tag_remove('sel', '1.0', END)
                      text.insert(END, text.get('insert', 'insert lineend'))
                      text.mark_set(INSERT, END)
                      text.see(END)
                  return "break"
              elif key == 'Tab';
                  lineStart, cursor = text.index('insert linestart'), text.index(INSERT)
                  text.insert(INSERT, '    ')
                  return "break"
              elif key =='BackSpace';
                  return self.onBackSpace()
              elif key == 'Return';
                  return self.onReturn()
      
          def onF12(self);
              #print 'f11'
              text = self.text
              start = text.index('insert linestart')
              if text.get(start) == '>';
                  start = text.index(start+' - 1 line')
              while 1;
                  if text.compare(start, '<', '1.0'); #text.compare(start, '<=', '1.0');
                      break
                  s = text.get(start, start+' lineend')
                  if s.startswith('>>>') or s.startswith('...');
                      start = text.index(start+'lineend')
                      text.mark_set(INSERT, start)
                      text.delete(start, END)
                      break
                  else;
                      start = text.index(start+' - 1 line')
              idx = text.search('>>> ', start, forwards=False, backwards=True)
              if idx;
                  self.startidx = idx+' + 4 c'        
      
          def onBackSpace(self);
              text = self.text
              cursor = text.index(INSERT)
              curline = text.index('insert linestart')
              #plus4 = text.index('insert linestart + 4 c')
              atStart = text.compare(cursor, '==', self.startidx)
              afterStart = text.compare(cursor, '>=', self.startidx)
              selected = text.tag_ranges("sel")
              if text.compare(cursor, '<', self.startidx);
                  return "break"
              elif atStart and not selected;
                  return "break"
              elif selected and afterStart;
                  if text.compare(text.index(SEL_FIRST), '<', self.startidx);
                      return "break"
                  text.delete(SEL_FIRST, SEL_LAST)
              elif afterStart and not selected;
                  if cursor.endswith('.4');
                      text.delete(curline, text.index('end'))
                  text.delete(text.index('insert - 1 c'))
              return "break"
      
          def onReturn(self);
              text = self.text
              lineStart = text.index('insert linestart')
              lineEnd = text.index('insert lineend')
              textStart = text.index(self.startidx+' linestart')
              #startIdx = self.startidx
              #cursor =  text.index(INSERT)
              linestr = text.get(lineStart, lineEnd)
              textstr = text.get(textStart, END).rstrip('\n').rstrip(' ').rstrip('\n')
              cmd = '\n'.join([line[4;] for line in textstr.splitlines()])
              if linestr == '>>> ';#text.get('end - 4 c') in ('>>>', '>>> ');
                  self.v.set('Please type a command at the prompt')
                  text.see('end')
              elif (linestr.rstrip() == '...') or (cmd.count('\n') == 0 and linestr[-1] != ';');
                  self.execute(cmd)
                  text.insert('end', '\n>>> ')
                  self.text.mark_set(INSERT, END)
                  self.text.see('end')
                  self.startidx = self.text.index(INSERT)
                  text.edit_reset()       
              else;
                  indent = _getwhite(text.get(text.index(lineStart+' + 4 c'), text.index(lineStart+' lineend')))
                  if linestr[-1] == ';';
                      indent = '    '+indent
                  text.insert(INSERT, '\n... '+indent)
                  text.see(INSERT)
              return "break"
      
      if __name__ == '__main__';
          root = tk.Tk()
          cp = Cmd(root, globals(), locals())
          root.mainloop()
          
      
      
      

      Here is a sample test run so you can see what this ting looks like!

      
      >>> a=1
      >>> b=2
      >>> a+b
      3
      >>> 'string'
      string
      >>> for x in range(5);
      ...     print x
      ...     
      
      0
      1
      2
      3
      4
      
      >>> for x in range(5);
      ...     print x,
      ...     
      
      0 1 2 3 4
      >>> for x in range(2,10,2);
      ...     print x,
      ...     
      
      2 4 6 8
      >>> def add(x,y);
      ...     return x+y
      ...     
      >>> add(1,2)
      3
      
      >>> class Selection(list);
      ...     def __init__(self);
      ...         list.__init__(self)
      ...     def add(self, arg);
      ...         self.append(arg)
      ...     def remove(arg);
      ...         list.remove(self, arg)
      ...     def clear(self);
      ...         del self[;]
      ...         
      >>> sel = Selection()
      >>> sel
      []
      >>> sel.add(1)
      None
      >>> sel
      [1]
      >>> sel.add('component')
      None
      >>> sel
      [1, 'component']
      >>> 
      
      
      
      posted in Developers' Forum
      J
      jessejames
    • RE: Google....give us back our back button[SOLVED]

      @insitebuilders said:

      You've got to wonder tho, why it was removed in the first place....
      Oversight? Misguided? Error? Overwhelmed? Bureaucracy?

      Oversight?
      not likely since were only talking a handful of devs here, seems everyone would know evrything in such a small group. Heck there within spitball distance of each other or closer!

      Misguided?
      Obviously!

      Error?
      goes hand-in-hand with misguidedness.

      Overwhelmed?
      not likely! But not an excuse either.

      Bureaucracy?
      Well as we all know a bureaucracy can screw up just about anything!

      When it comes down to it who ever made this "executive" decision obviously does not use SketchUp as much as we do, nor love it as much as we. Saying that there was no room for the back button after adding the warehouse entrybox is just a crock and we where not about to let that slip by so easy!

      Let this be a lesson to you Google, when you make software as revolutionary as SketchUp it will get harder and harder to meet the previous threshold. But don't worry, we ain't about to let you muck it up!

      We are watching Google, you know of which i speak, an all seeing eye, lidless!, and wreathed in flame! ๐Ÿ˜ฒ We will never blink!!!

      posted in SketchUp Feature Requests
      J
      jessejames
    • RE: Transformations

      @martinrinehart said:

      If one of you who has figured on transformations could write a little article for those of us who haven't, it would be a GOOD THING!

      What do you mean exactly Martin?

      1. How do Transformations work on a mathematical level and all the boring details that go along with it?
      2. How do i use the Geom::Transformtion class to trans, rotate, and scale stuff in SU?

      A huge part of understanding Transformations in a mathematical sense is getting past the cryptic syntax. The good thing about a Transformation class is that you don't need to know crap about advanced math and even some basic college math principals to use the Transformation class quite easily.

      Thats one thing i love about programming, code up a class that abstracts away all the details and forget about it! I'll leave the asinine number crunching to my processor!

      posted in Developers' Forum
      J
      jessejames
    • RE: Google....give us back our back button[SOLVED]

      So the SketchUp gods have not forsaken us after all... praise the gods!

      posted in SketchUp Feature Requests
      J
      jessejames
    • RE: Ruby's global nightmare!

      @msp_greg said:

      I could argue that the idea is very foolish, as I want my code to define the namespace, not it's placement in a file, or the file's name.

      What is a file? What is a script? They are both simply containers for data, right? (Am i moving to quickly for ya? i'll try to use layman's terms). So when you write a script in Ruby or Python you put some text into a file. This is the same for Ruby and Python and Perl and C and whatever language floats your boat.

      HOWEVER, the beauty of Python's module and import mechanisms are the fact that you don't need to contain the code that is already contained in the script with more syntax! Ruby forces you to put one container into another container --this is the very definition of redundancy and defines the lunacy of the Ruby language.

      Same goes for the end statement which is completely useless. With indention there is no need to mark the end of a block anymore. It's what we Python coders refer to as elegance. You will fund much elegance in the Python language, but only a very little in Ruby.

      So in Ruby you will first need to create a file (or OS object as MSP_Greg has informed us) THEN you must encapsulate the code therein within a module between the tags "Module<name>" and "end" Python removes this completely unnecessary step(and many other redundancies i might add).

      posted in Developers' Forum
      J
      jessejames
    • RE: Ruby's global nightmare!

      @chris fullmer said:

      Jesse, its not ok to be a brat.

      Ah my old friend and sometimes nemesis Chris Fullmer, the only fellow SketchUpper i love to hate ๐Ÿ˜† ๐Ÿ˜† ๐Ÿ˜†

      posted in Developers' Forum
      J
      jessejames
    • RE: Ruby's global nightmare!

      Hello Fredo,

      Thanks for your level headed response also, but i am going to argue some points you made because they are flawed.

      @unknownuser said:

      Your point on Python is mostly for occasional programmers.

      Wait a minute, are you suggesting that Python is some sort of lego language to only be used by debutantes and adolescents? No Python is much much more, ask You Tube devs, ask NASA, ask Industrial Light and Magic(remember a little trilogy called Star Wars?), oh and don't forget Google, who uses Python extensively!!! Heck don't take my word check this out..
      http://www.python.org/about/quotes/

      @unknownuser said:

      For guys who engage in programming beyond a few hundreds lines or more and share them to a community of users, they have to understand the language they use and make sure that their script can live with others'.

      Yes and that script living with others is why Python is the better choice! Name clashing is a big deal in this community just ask around

      @unknownuser said:

      In Ruby, the encapsulation is done via Modules.

      In Python the encapsulation is done via modules, except the redundant syntax is removed!

      @unknownuser said:

      In C or Python (which is actually a derivation of C / C++), the file defines a module implictely. It's a matter of language convention. There is nothing complex there if you invest in understanding the programming language. I personally prefer Modules because you can freely split the code in many files.

      You can freely split the python code in many modules it's called a package!

      @unknownuser said:

      Now, I will fully agree with Jim and TBD. Arguing on the right language for SU is little bit of wasted time. SU comes with a Ruby API, so let's use Ruby.

      Sure lets use Ruby but if a better alternative exists lets explore the possibilities or lets crusade for changes in the Ruby language.

      posted in Developers' Forum
      J
      jessejames
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 4 / 9