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

    Store Patterned Data

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 226 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.
    • pingpinkP Offline
      pingpink
      last edited by

      I'm trying to store patterned data to recheck the design for later use of different coloured panels.

      Process Steps :

      1. Select a patterned model.

      2. The patterns are convert into a group and in a layer "Patterns" and be invisible temporary.

      3. Only the sub-dividing faces are shown , later I can open the patterned group.

      The problem is the patterned group is copied and invisible , but the edges which are drawn in a layer " Patterns " cut and divide each face that is not a panel. I try to learn the code from Tig's example. Very good example , I wonder how can I clear the edges that cut faces ?

      def group_hide_patterns
      
      #EDGES-GROUP
      
      model=Sketchup.active_model
      edges=[]
      ss=model.selection
      ss.grep(Sketchup;;Face).each{|face| edges << face.edges}
      ss.grep(Sketchup;;Edge).each{|edge| edges << edge}
      edges.flatten!
      edges.uniq!
      edges.compact!
      
      ents=model.active_entities
      group=ents.add_group(edges)
      group.name="patterns"
      
      	edge_layer = model.layers.add("Patterns")
      	if group.name="patterns"
      
      	ss.each{|e|
      	e.layer = edge_layer  if e.is_a? Sketchup;;Group
      
      	}
      	 
      		edge_layer.visible = false
      	end
      
      end
      

      Process Steps


      Problem


      Apply

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Groups/components will separate geometry, so keeping panel divisions in a separate group.entities will mean they won't cut faces that remain inside in another entities context.
        It is much better to use layers to hide/show groups or component-instances and keep all of your raw geometry [edges and faces] on Layer0. Layers or using Hidden=true don't separate geometry.

        BUT if you have an edge that is splitting a face [i.e. they must all be in the same context] - aka a coplanar edge - then there are several examples of code to delete such edges.
        Here's one [pretty much unpublished] pick the meat off the bones...

        ### Delete Coplanar Edges
        # TIG (c) 2008-2013
        ###
        require 'sketchup.rb'
        ###
        module TIG
        
        def self.deleteCoplanarEdges_validate_selection()
        	Sketchup.active_model.selection.each{|e|
        		if e.is_a?(Sketchup;;Edge) && e.faces.length==2
        			return true
        			break
        		end#if
        	}
        	return false
        end
        
        def self.deleteCoplanarEdges()
        	model=Sketchup.active_model
        	edges=model.selection.grep(Sketchup;;Edge).find_all{|e| e.faces.length==2 }
        	togos=[]
        	counter=0 
        	model.start_operation("Delete Coplanar Edges")
        	edges.each{|e|
        		next unless e.valid?
        		if e.faces[0].normal.dot(e.faces[1].normal) > 0.99999999 && e.faces[0].material == e.faces[1].material && e.faces[0].back_material == e.faces[1].back_material
        			togos << e
        			counter+=1
        			Sketchup;;set_status_text(("Coplanar Edges Erased = #{counter}"),SB_PROMPT)
        		end#if
        	}
        	model.active_entities.erase_entities(togos)
        	model.commit_operation
        end
        
        ###
        unless file_loaded?(__FILE__)
        	UI.add_context_menu_handler{|menu|
        		if self.deleteCoplanarEdges_validate_selection()
        			menu.add_item("Delete COPLANAR Edges"){self.deleteCoplanarEdges()}
        		end#if
        	}
        end#unless
        file_loaded(__FILE__)
        
        end#module
        

        TIG

        1 Reply Last reply Reply Quote 0
        • pingpinkP Offline
          pingpink
          last edited by

          I rethink again , maybe I have to separate between panel faces and pattern group ? πŸ˜„


          Method

          1 Reply Last reply Reply Quote 0
          • pingpinkP Offline
            pingpink
            last edited by

            Thank You So much,Tig. It works ! πŸ˜„

            This is the idea to revise a model from architect by storing data at the first time. And later use to recheck data for tagging panels , and take the panel out in order that the facade engineer can do the life size panels to do mapping back on sub-dividing panels.

            The method I do :
            The subdividing faces are in the "Layer0".
            The patterns are in the Layer-"Patterns".
            So , they are not mix together in the same layer.

            For the shortage time to "delete coplanar edges or patterns" , I have to select edges by degrees and use your code to delete edges because the group edge and original edges are overlap that I have to delete original edges.So , it doesn't affect to bring tagging panels out , and I can recheck the patterned data to do retag panels.

            For the store patterned data , maybe it comprise of 3 functions :

            1.Make edge group
            2.Select Coplanar edges by degrees
            3.Delete Coplanar edges selection

            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