How to recognize cursor on top of texture?
-
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 ImageBut 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!
-
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!
-
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!
-
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. -
@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!
-
@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 != nilIf selected_face_mat is nil then you cannot call .texture on it.
Advertisement