Medeek Wall

@medeek , I’m wondering if you can tell me the ruby command to regenerate a Medeek wall? Consider this a low-key request for the beginning of the Medeek Wall API :wink:

Instead of making a feature request, I decided to create my own feature, lol. I’ve come up with a proof of concept utility to help me reconfigure the correct number of jack and king studs AUTOMATICALLY for all doors and windows in the selected Medeek walls. It’s becoming mind-numbing to have to check this schedule manually for every single opening. It configures them according to the structural engineer’s schedule in the plans I’m working on. They have it laid out with logic according to whether it’s an interior/exterior wall and based on the width of the opening.

(They also have different requirements depending on the level of the building the headers are located, but I haven’t gotten that far yet…)

I’ve pretty easily been able to figure out how to grab the attributes I need from the Medeek Wall to check these things and update the jacks and kings for each opening, but I’d love to be able to include the command right in my script to regen the wall so I don’t have to do it manually.

(To use this script, select one or more Medeek walls, then copy and paste this into Ruby console. All jacks/Kings will be reconfigured to conform to the schedule above)

  	def self.jackKing
		model = Sketchup.active_model
		ents = model.entities
		selection = model.selection
		
		#Loop through each group/component
		selection.each do |entity|
          	if entity.is_a?(Sketchup::Group) || entity.is_a?(Sketchup::ComponentInstance)
				#First, we need to grab the attributes we need from the wall
				selDict = entity.attribute_dictionaries
				medeek_wall_param5 = selDict['medeek_wall_param5']
				medeek_wall_param = selDict['medeek_wall_param']

				if medeek_wall_param5 and medeek_wall_param # make sure this is a Medeek wall
					wallType = medeek_wall_param["WALLTYPE"]
					#need to loop through each opening
					medeek_wall_param5.each { | key, value |
						#Door = 5,6 Window = 7,8

						#doorParams = medeek_wall_param5["DOOR1"]
						doorWidth = value[2]
						if key.start_with?('DOOR')
							value[5] = self.choosejacks(doorWidth, wallType)[1]
							value[6] = self.choosejacks(doorWidth, wallType)[0]
						elsif key.start_with?('WINDOW')
							value[7] = self.choosejacks(doorWidth, wallType)[1]
							value[8] = self.choosejacks(doorWidth, wallType)[0]
						end
						entity.set_attribute "medeek_wall_param5", key, value
					}
				end
			end
		end
  	end

  	def self.choosejacks(width, wallType)

  		#Need to toggle which level of building we are on
  		if width <= 42
  			if wallType == "Int-Int"
				jacksKings = [1,3]
			elsif wallType == "Int-Ext"
				jacksKings = [1,2]
			end
  		elsif width > 42 and width <= 72
  			if wallType == "Int-Int"
				jacksKings = [2,4]
			elsif wallType == "Int-Ext"
				jacksKings = [2,2]
			end
  		elsif width > 72 and width < 108
  			if wallType == "Int-Int"
				jacksKings = [2,3]
			elsif wallType == "Int-Ext"
				jacksKings = [2,3]
			end			
		else
			UI.messagebox("Opening too wide")
  		end
  		return jacksKings
  	end

  	self.jackKing
1 Like