sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to recognize cursor on top of texture?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 225 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • renderizaR Offline
      renderiza
      last edited by

      Hi, I am about to finish my next update for Canvas plugin but I am having trouble with cursor on top of texture. Here is link to Canvas... http://sketchucation.com/forums/viewtopic.php?f=323&t=51655

      So Far I have this done;

      Add:: On Vertex
      Add:: On Edge
      Add:: On Face
      Add:: Group
      Add:: Component
      Add:: On Image

      But I still trying to finish these;

      Add:: On Texture - Can't solve it at the momment 😞
      Add:: On Shadow - (I made a thread asking this and I am close to finishing it...just need little more time)
      Add:: On Selection - (Have not tried yet so don't know if I will have problems)

      I tried this;

      
      def onMouseMove(flags,x,y,view)
      
      ip1 = view.inputpoint x,y ;
      point = ip1.position ;
      
      select_comp=view.pick_helper
      select_comp.do_pick x,y
      selected_comp=select_comp.best_picked
      
       if flags == 1 && @@sel != nil && @@texture_addon == true && selected_comp.is_a (Sketchup;;Texture) == true
         add_object(point) ;
       end 
      end #def
      

      Thanks in Advance!

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • renderizaR Offline
        renderiza
        last edited by

        Here is a WIP

        I managed to recognize the material by doing this;

        select_comp=view.pick_helper
        select_comp.do_pick x,y
        selected_face=select_comp.picked_face
        selected_face_mat=selected_face.material
        
        # Add On Texture 	
        if flags == 1 && @@sel != nil && @@texture_addon == true && selected_face_mat != nil
        	add_object(point) ;
        end 
        

        Now I need see how I can integrate texture material in there....wish me luck!

        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          I feel weird replying to my own posts but I solved it!

          Just need to add .texture at the en of selected_face_mat like this...selected_face_mat.texture

          
          select_comp=view.pick_helper
          select_comp.do_pick x,y
          selected_face=select_comp.picked_face
          selected_face_mat=selected_face.material
          
          # Add On Texture    
          if flags == 1 && @@sel != nil && @@texture_addon == true && selected_face_mat.texture != nil
             add_object(point) ;
          end 
          

          Cheers!

          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            That won't work if the face have the default material - in which case selected_face.material will return nil - and you can't call nil.texture

            Also - no need to do: selected_face_mat.texture != nil
            nil evaluates to false and any other value evaluates to true.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • renderizaR Offline
              renderiza
              last edited by

              @thomthom said:

              That won't work if the face have the default material - in which case selected_face.material will return nil - and you can't call nil.texture

              Also - no need to do: selected_face_mat.texture != nil
              nil evaluates to false and any other value evaluates to true.

              For the Canvas Plugins now have this two Add:: On Features;

              Add:: On Material - I am actually happy that the default material returns nil because it may pass as a mask feature πŸ‘

              Add:: On Texture - This one is working as it should at the momment adding groups or Coponents on top of entities with textures only and ignores any kind of entities with material color only & no texture image.

              Cheers!

              [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @unknownuser said:

                Add:: On Material - I am actually happy that the default material returns nil because it may pass as a mask feature πŸ‘

                But this line will cause an error:
                if flags == 1 && @@sel != nil && @@texture_addon == true && selected_face_mat.texture != nil

                If selected_face_mat is nil then you cannot call .texture on it.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement