require 'sketchup.rb' class RSjww # メイン def rs_jw_get Sketchup.set_status_text("Initializing.") #/ ////////// 初期設定 ////////// #Jwwのインストールフォルダ $rs_jw_path='d:/jww/' #このプラグインで開くファイル $rs_jw_path += 'RSJww_tmp.txt' #コンポーネントフォルダ $rs_comp_path =Sketchup.find_support_file("Components")+"/" #テクスチャフォルダ @rs_tx_path='d:/jww/texture/' #生成するマテリアル名ヘッダ mat_head = "Jw_" #/ ////////// ダイアログの初期値セット ////////// mes_0 = "全体をグループ化" $rsjww_group_yesno = "Yes" if not $rsjww_group_yesno list0 = ["Yes","No"] mes_1 = "レイヤ別にグループ化" $rsjww_ly_group_yesno = "Yes" if not $rsjww_ly_group_yesno list1 = ["Yes","No"] mes_2 = "レイヤを分ける" $rsjww_layer_yesno = "Yes" if not $rsjww_layer_yesno list2 = ["Yes","No"] mes_3 = "生成可能な面を張る" $rsjww_face_yesno = "No" if not $rsjww_face_yesno list3 = ["Yes","No"] mes_4 = "テクスチャを上書きする" $rsjww_texture_yesno = "Yes" if not $rsjww_texture_yesno list4 = ["Yes","No"] mes_5 = "文字を取り込む" $rsjww_text_yesno = "Yes" if not $rsjww_text_yesno list5 = ["Yes","No"] mes_6 = "文字のエッジを消す(長時間注意)" $rsjww_textedge_yesno = "No" if not $rsjww_textedge_yesno list6 = ["Yes","No"] mes_7 = "2.5D文字検索精度" $rsjww_seido = 5 if not $rsjww_seido list7 = [14,13,12,11,10,9,8,7,6,5,4,3] mes_8 = "円管分割角(無指定時)" $rsjww_eksec = 30 if not $rsjww_eksec list8 = [1,3,6,10,15,30,45,60,90] #処理時間に影響大 mes_9 = "円分割角(無指定時)" $rsjww_cisec = 15 if not $rsjww_cisec list9 = [1,3,6,10,15,30,45,60,90] mes_10 = "補助線変換" $rsjww_lc9_lt9 = "No" if not $rsjww_lc9_lt9 list10 = ["Yes","No"] mes_11 = "円管ボールジョイント" $rsjww_balljoint = "No" if not $rsjww_balljoint list11 = ["Yes","No"] prompts = [mes_0,mes_1,mes_2,mes_3,mes_4,mes_5,mes_6,mes_7,mes_8,mes_9,mes_10,mes_11] values = [$rsjww_group_yesno,$rsjww_ly_group_yesno,$rsjww_layer_yesno,$rsjww_face_yesno,$rsjww_texture_yesno,$rsjww_text_yesno,$rsjww_textedge_yesno,$rsjww_seido,$rsjww_eksec,$rsjww_cisec,$rsjww_lc9_lt9,$rsjww_balljoint] com = [list0.join("|"),list1.join("|"),list2.join("|"),list3.join("|"),list4.join("|"),list5.join("|"),list6.join("|"),list7.join("|"),list8.join("|"),list9.join("|"),list10.join("|"),list11.join("|")] results = inputbox prompts, values, com,"変換条件設定" if not results load"RSJww.rb" p 'Reloaded '+Time.now.to_s return end #if $rsjww_group_yesno = results[0] $rsjww_ly_group_yesno = results[1] $rsjww_layer_yesno = results[2] $rsjww_face_yesno = results[3] $rsjww_texture_yesno = results[4] $rsjww_text_yesno = results[5] $rsjww_textedge_yesno = results[6] $rsjww_seido = results[7] $rsjww_eksec = results[8] $rsjww_cisec = results[9] $rsjww_lc9_lt9 = results[10] $rsjww_balljoint = results[11] #/ ////////// 本体ここから ////////// model = Sketchup.active_model @entities = model.active_entities layers = model.layers view = model.active_view materials = model.materials shadowinfo = model.shadow_info model.start_operation('rs_jw_get',true) x_ax = Geom::Vector3d.new 1,0,0 y_ax = Geom::Vector3d.new 0,1,0 z_ax = (Geom::Vector3d.new 0,0,1).normalize! q=" " h_rand = 0 #// ストップウォッチ start_time=Time.now #//////////////////////////////////// #/ 2.5D・日影文字回収 #//////////////////////////////////// d25enkan = {} d25kakukan = {} d25moji = {} seido = $rsjww_seido Sketchup.set_status_text("retrieving letters > 2.5D , shadow") open($rs_jw_path) {|file| while c = file.gets c.chomp! lg_=c[0..2] if c[0..1] == "lg" ly_=c[0..2] if c[0..1] == "ly" #デフォルト値0のハッシュに格納 if c[0..2] == "c2 " || c[0..2] == "cz " tmp=c.split tmp2=c.split('"') if c[-1,1] == "T" #円管 d25enkan[lg_ + ly_ + q + tmp[1][0..seido] + q + tmp[2][0..seido]] = tmp2[1].gsub('T',"") elsif c[-1,1] == "D" #四角管 d25kakukan[lg_ + ly_ + q + tmp[1][0..seido] + q + tmp[2][0..seido]] = tmp2[1].gsub('D',"") else d25moji[lg_ + ly_ + q + tmp[1][0..seido] + q + tmp[2][0..seido]] = tmp2[1][0..-1] end #if end end #while } #//////////////////////////////////// #/ lv,lh回収・レイヤ名回収 #//////////////////////////////////// #「#lv」用のハッシュを用意 lv_lg = Hash.new(0.m) lv_ly = Hash.new(0.m) lgly_name = Hash.new("") #「#lh」用のハッシュを用意 lh_ly1 = Hash.new(nil) lh_ly2 = Hash.new(nil) Sketchup.set_status_text("retrieving letters > lgn , lyn") open($rs_jw_path) {|file| while c = file.gets c.chomp! begin#V8_2014 c.encode!("UTF-8", "Shift_JIS", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") rescue end lg_= c[0..2] if c[0..1] == "lg" && c[2..2]!="n" lgly = lg_ + c[0..2] if c[0..1] == "ly" && c[2..2]!="n" #レイヤグループ名定義部分か否か if c[0..1] == "lg" && ( c.length>3 || c[0..2]= "lgn" ) if c[2..2] != "n"#4文字目が'n'以外ならレイヤグループ番号 lv_lg_name=c[0..2]#lv用 end #if #lgn取得 if c[0..2] == "lgn" if c.length == 3 lg_name_tmp = " " else lg_name_tmp = c[3..-1]#レイヤグループ名取得 end #if #lv_lg取得 lv_tmp = 0.m if c.include?("#lv") lv_tmp = c[c.index("#lv")+3..-1].to_f.m end #if lv_lg[lv_lg_name] = lv_tmp end #if end #if #レイヤ名定義部分か否か if c[0..1] == "ly" && ( c.length>3 || c[0..2]=="lyn" ) if c[2..2] != "n"#3文字目が'n'以外ならレイヤ番号 lv_ly_name = c[0..2] end #if #lyn取得 if c[0..2] == "lyn" if c.length == 3 ly_name_tmp = " " #名前無しはブランク else ly_name_tmp = c[3..-1]#レイヤ名取得 end #if lntmp= "[" + lv_lg_name[-1..-1] + "-" + lv_ly_name[-1..-1] +"] " + lg_name_tmp + " - " + ly_name_tmp lgly_name[lv_lg_name + lv_ly_name] = lntmp#ハッシュにlgly名を格納 #lv_ly lv_tmp = 0.m if c.include?("#lv") lv_tmp = c[c.index("#lv")+3..-1].to_f.m end #if lv_ly[lv_lg_name+lv_ly_name] = lv_tmp #lh_ly取得 lh_tmp1 = nil lh_tmp2 = nil if c.include?("lyn") && c.include?("#lh") lh_tmp = c[c.index("#lh")+3..-1] if lh_tmp.include?(",") tmp = lh_tmp.split(",") lh_tmp1 = tmp[0].to_f.m lh_tmp2 = tmp[1].to_f.m else lh_tmp1 = c[6..-1].to_f.m lh_tmp2 = 0 end#if end #if lh_ly1[lgly] = lh_tmp1 lh_ly2[lgly] = lh_tmp2 end #if end #if end #while } #//////////////////////////////////// #/ 真北角度回収 #//////////////////////////////////// @rsjww_north = shadowinfo["NorthAngle"] @rsjww_north = 0 if not @rsjww_north houi_settei = "" Sketchup.set_status_text("retrieving letters > north") open($rs_jw_path) {|file| while l = file.gets #真北角度値検索(2012-11-16追加) if l[0..1] == "ck" begin ll = l.encode!("UTF-8", "Shift_JIS").split('"') rescue ll = l.split('"') end if ll[1].index(".") shadowinfo["NorthAngle"] = -ll[1].to_f @rsjww_north = shadowinfo["NorthAngle"] end # if houi_settei = "真北角度:" + shadowinfo["NorthAngle"].to_s + "\n" break end # if end #while } #//////////////////////////////////// #/ JWWの使用レイヤとグループをSUに登録 #//////////////////////////////////// rsjw_group=@entities.add_group#.entities rsjw_group.name="RSJww " + Time.now.to_s.gsub(" ","_") @ly_name=[] @ly = {} @gr = {} for tmp in layers @ly_name << tmp.name end #for lgly = nil @layer_n = 0 Sketchup.set_status_text("preparing Groups") open($rs_jw_path) {|file| while c = file.gets if c[0..1] == "lg" lg_= c[0..2] end #if if c[0..1] == "ly" lgly = lg_ + c[0..2] if lgly.length==6 lyn=lgly_name[lgly] if $rsjww_layer_yesno=="Yes" Sketchup.set_status_text("Layer setting " + @layer_n.to_s) if @ly.include?(lyn) == false @ly[lyn] = layers.add lyn @layer_n+=1 end #if end #if #// 名前付グループを予約 if @gr.include?(lyn) == false @gr[lyn] = rsjw_group.entities.add_group # @gr[lyn] = model.entities.add_group @gr[lyn].name = lyn @gr[lyn].layer=layers[lyn] if $rsjww_layer_yesno=="Yes" end #if end #if end #if break if c[0..2] == "lgn" end #while } #//////////////////////////////////// #/ マテリアル定義 #//////////////////////////////////// mt=[]#mtに既存マテリアル名を格納 for tmp in materials mt << tmp.name end #for @TX_err = "" mat_list = Hash::new("undefined") Sketchup.set_status_text "Materials setting." open($rs_jw_path) {|file| while c = file.gets c.chomp! begin#V8_2014 c.encode!("UTF-8", "Shift_JIS", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") rescue end if c.include?('"@TX') #マテリアル定義文字 tmp = c.split('"')[1].split(",") cc = tmp[0][3..-1] #cのヘッダを除去 mat = mat_head + cc #マテリアル名生成 mat_list[cc] = mat #マテリアル名をハッシュに登録 begin Integer( tmp[1] ) #整数値が書かれていれば色 if mt.include?(mat) == false#同じマテリアル名が無ければ追加 mt< :replace, :undef => :replace, :replace => '?').encode("UTF-8") rescue end ens = c.split #// ついでに要素を数える en+=1 if c[0..0] == " " || ( c[0..2] == "sl " && ens.length == 5 )#線・線形ソリッドカウント yn+=1 if c[0..2] == "ci "#円カウント sn+=1 if c[0..2] == "sl "#ソリッドカウント sn+=1 if c[0..2] == "sc "#円ソリッドカウント mn+=1 if c[0..2] == "ch " || c[0..2] == "cv "#文字カウント cc=c[0..2] if c[0..1] == "lc"#標準色はlcを記録 cc=c[5..-1].chomp if c[0..4] == "lc10 "#任意色は色コードを記録 #// 任意色を重複しないように追加 if c[0..1] == "sl" || c[0..1] == "sc" #ソリッドに適用される色を検索 Sketchup.set_status_text "Collecting colors." + n.to_s mat=mat_head + cc mat_list[cc] = mat #マテリアル名をハッシュに登録 #マテリアルを生成 if cc[0..1] == "lc" #標準色 if mt.include?(mat) == false mt<5 @z1 = 0 @z2 = 0 #// 2.5D文字とマッチング za = [lh_ly1[lgly].to_f,lh_ly2[lgly].to_f] zb = [lh_ly1[lgly].to_f,lh_ly2[lgly].to_f] zc = [lh_ly1[lgly].to_f,lh_ly2[lgly].to_f] zd = [lh_ly1[lgly].to_f,lh_ly2[lgly].to_f] #// ハッシュ処理 #1つめの頂点 key=d25moji[lgly + q + tmp[1][0..seido] + q + tmp[2][0..seido]] if key split25ds(key) za[0] = @z1 za[1] = @z2 end #if #2つめの頂点 key=d25moji[lgly + q + tmp[3][0..seido] + q + tmp[4][0..seido]] if key split25ds(key) zb[0] = @z1 zb[1] = @z2 end #if #3つめの頂点 key=d25moji[lgly + q + tmp[5][0..seido] + q + tmp[6][0..seido]] if key split25ds(key) zc[0] = @z1 zc[1] = @z2 end #if #4つめの頂点 if tmp.length == 9 key = d25moji[lgly + q + tmp[7][0..seido] + q + tmp[8][0..seido]] if key split25ds(key) zd[0] = @z1 zd[1] = @z2 end #if end if #// 面処理 if tmp.length == 9 || tmp.length == 7 face_n = 1 else face_n = 0 end for i in 0..face_n do pt = [] pt<<[tmp[1].to_f.mm,tmp[2].to_f.mm,za[i]+lv] pt<<[tmp[3].to_f.mm,tmp[4].to_f.mm,zb[i]+lv] pt<<[tmp[5].to_f.mm,tmp[6].to_f.mm,zc[i]+lv] pt<<[tmp[7].to_f.mm,tmp[8].to_f.mm,zd[i]+lv] if tmp.length==9 #// 三角面を張る if tmp.length == 7 begin face = @gr[lgly_name[lgly]].entities.add_face pt face.material = mat_name face.back_material = mat_name face.reverse! if face.normal != z_ax rescue error_face +=1 end end #if #// 四角面を張る if tmp.length == 9 begin face = @gr[lgly_name[lgly]].entities.add_face pt face.material = face.back_material = mat_name face.reverse! if face.normal != z_ax #// 面が構成できない四角は任意の三角に分割して面を張る rescue begin pt=[] pt<<[tmp[1].to_f.mm,tmp[2].to_f.mm,za[i]+lv] pt<<[tmp[3].to_f.mm,tmp[4].to_f.mm,zb[i]+lv] pt<<[tmp[5].to_f.mm,tmp[6].to_f.mm,zc[i]+lv] face = @gr[lgly_name[lgly]].entities.add_face pt face.material = mat_name face.back_material = mat_name z_ax = Geom::Vector3d.new 0,0,1 face.reverse! if face.normal != z_ax begin pt=[] pt<<[tmp[1].to_f.mm,tmp[2].to_f.mm,za[i]+lv] pt<<[tmp[5].to_f.mm,tmp[6].to_f.mm,zc[i]+lv] pt<<[tmp[7].to_f.mm,tmp[8].to_f.mm,zd[i]+lv] face = @gr[lgly_name[lgly]].entities.add_face pt face.material = mat_name face.back_material = mat_name face.reverse! if face.normal != z_ax error_face +=1 rescue error_face +=1 end rescue error_face +=1 end end end #if end #for end #if end #if end #while } #ソリッドの輪郭を非表示にする場合は下の三行を有効化 #for tmp in @entities # status = tmp.hidden = true if tmp.typename == "Edge" #end #//////////////////////////////////// #/ 線・円要素等取り込み #//////////////////////////////////// es = 0 youso_n = 0 err_ci = 0 err_mes = "" open($rs_jw_path) {|file| while l = file.gets youso_n+=1 break if l[0..3]=="lg0 "#レイヤ定義でbreak lc_ = l[0..2] if l[0..1] == "lc" lt_ = l[0..2] if l[0..1] == "lt" ly_ = l[0..2] if l[0..1] == "ly" lg_ = l[0..2] if l[0..1] == "lg" lgly = lg_+ly_ if lg_ && ly_ lv = lv_lg[lg_]+lv_ly[lg_.to_s+ly_.to_s] cc = l[5..-1].chomp if l[0..4] == "lc10 " lyn = lgly_name[lgly] #// 線 #文字コード処理 begin#V8,2014 l.encode!("UTF-8", "Shift_JIS", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") rescue end tmp = l.split #// 線と線形ソリッドを対象に #補助線出力判断 if $rsjww_lc9_lt9=="No" && (lt_ == "lt9" || lc_ == "lc9") hojo=false else hojo=true end#if if (l[0..0] == " " && hojo) || ( l[0..2] == "sl " && tmp.length == 5) es += 1 Sketchup.set_status_text("[Line].Ci.sc.Arc " + es.to_s + "/" + (en+yn).to_s) #// レイヤ分け model.active_layer = @ly[lyn] if $rsjww_layer_yesno == "Yes" ss = 0 #線 ss = 1 if l[0..1] == "sl" #線形ソリッド x1 = tmp[ss].to_f.mm y1 = tmp[ss+1].to_f.mm x2 = tmp[ss+2].to_f.mm y2 = tmp[ss+3].to_f.mm #マテリアル設定 if l[0..2] == "sl "||l[0..2] == "sc " mat_name = mat_list[cc] else mat_name = mat_head + lc_ + lt_ + ly_ if mt.include?(mat_name) == false mt << mat_name mat_list[cc] = mat_name add_color_material(mat_name ,255 ,255 ,255 ,1) end #if end #if #// 2.5D円管文字とマッチング if d25enkan.length>0 zpa = nil #za:端点aのz座標 zpb = nil #zb:端点bのz座標 @zr = 0 #zr:半径 zk = $rsjww_eksec #zk:分割角 done = nil # 実行の記録 #1つめの頂点 key = d25enkan[lgly + q + tmp[ss][0..seido] + q + tmp[ss+1][0..seido]] if key split25de(key) zpa = @z1 zk = @zs if @zs > 0 end #if #2つめの頂点 key = d25enkan[lgly + q + tmp[ss+2][0..seido] + q + tmp[ss+3][0..seido]] if key split25de(key) zpb = @z1 zk = @zs if @zs > 0 end #if #// 単線フォローミー if zpa && zpb c_seg = (360/zk).to_i c_point = [x1,y1,zpa+lv] c_point2 = [x2,y2,zpb+lv] c_vector = Geom::Vector3d.new x2-x1,y2-y1,zpb-zpa c_edges = @gr[lyn].entities.add_circle c_point, c_vector, @zr, c_seg c_face = @gr[lyn].entities.add_face c_edges c_face.material = mat_name c_face.back_material = mat_name line = @gr[lyn].entities.add_line c_point,c_point2 pipe = c_face.followme line done = true end #if end #if #// 2.5D角管文字とマッチング if d25kakukan.length>0 zpa = nil #za:端点aのz座標 zpb = nil #zb:端点bのz座標 @zw = 0 #zw:W @zh = 0 #zh:H #1つめの頂点 key = d25kakukan[lgly + q + tmp[ss][0..seido] + q + tmp[ss+1][0..seido]] if key split25dk(key) zpa = @z1 dw = @dw/2 if @dw > 0 dh = @dh/2 if @dh > 0 end #if #2つめの頂点 key = d25kakukan[lgly + q + tmp[ss+2][0..seido] + q + tmp[ss+3][0..seido]] if key split25dk(key) zpb = @z1 d_w = @dw/2 if @dw > 0 d_h = @dh/2 if @dh > 0 end #if #// 単線フォローミー if zpa && zpb point1 = [x1,y1,zpa+lv] point2 = [x2,y2,zpb+lv] teihen = Math.sqrt((x2-x1)**2+(y2-y1)**2) takasa = (zpa-zpb).abs d_rad = Math.atan2(y2-y1,x2-x1) + Math.atan2(1,0) if teihen>takasa#緩勾配 stretch= 1/(Math.cos(Math.atan2(takasa,teihen))) #// 角管断面 dx1 = x1 + Math.cos(d_rad)* d_w dy1 = y1 + Math.sin(d_rad)* d_w dx2 = x1 - Math.cos(d_rad)* d_w dy2 = y1 - Math.sin(d_rad)* d_w dz1 = zpa + lv +d_h*stretch dz2 = zpa + lv -d_h*stretch #Face pt = [] pt<<[dx1,dy1,dz1] pt<<[dx1,dy1,dz2] pt<<[dx2,dy2,dz2] pt<<[dx2,dy2,dz1] elsif#急勾配 stretch= 1/(Math.sin(Math.atan2(takasa,teihen))) dx1 = x1 + Math.cos(d_rad)* d_w - Math.sin(d_rad)* d_h dy1 = y1 + Math.sin(d_rad)* d_w + Math.cos(d_rad)* d_h dx2 = x1 + Math.cos(d_rad)*-d_w - Math.sin(d_rad)* d_h dy2 = y1 + Math.sin(d_rad)*-d_w + Math.cos(d_rad)* d_h dx3 = x1 + Math.cos(d_rad)*-d_w - Math.sin(d_rad)*-d_h dy3 = y1 + Math.sin(d_rad)*-d_w + Math.cos(d_rad)*-d_h dx4 = x1 + Math.cos(d_rad)* d_w - Math.sin(d_rad)*-d_h dy4 = y1 + Math.sin(d_rad)* d_w + Math.cos(d_rad)*-d_h #Face dz0= zpa + lv pt = [] pt<<[dx1,dy1,dz0] pt<<[dx2,dy2,dz0] pt<<[dx3,dy3,dz0] pt<<[dx4,dy4,dz0] end #if face = @gr[lyn].entities.add_face pt face.material = mat_name face.back_material = mat_name line = @gr[lyn].entities.add_line point1,point2 pipe = face.followme line done = true end #if end #if #//  ボールジョイント if zpa && zpb && $rsjww_balljoint=="Yes" b_vec1=[0,0,1] b_vec2=[1,0,0] b_edges = @gr[lyn].entities.add_circle c_point, b_vec1, @zr,c_seg b_face=@gr[lyn].entities.add_face b_edges b_face.material=mat_name b_face.back_material=mat_name line = @gr[lyn].entities.add_circle c_point, b_vec2, @zr,c_seg pipe = b_face.followme line b_vec1=[0,0,1] b_vec2=[1,0,0] b_edges = @gr[lyn].entities.add_circle c_point2, b_vec1, @zr,c_seg b_face=@gr[lyn].entities.add_face b_edges b_face.material=mat_name b_face.back_material=mat_name line = @gr[lyn].entities.add_circle c_point2, b_vec2, @zr,c_seg pipe = b_face.followme line end #if #//  2.5D文字とマッチング if done != true za1 = nil zb1 = nil za2 = nil zb2 = nil if d25moji.length>0 #1つめの頂点 key = d25moji[lgly + q + tmp[ss][0..seido] + q + tmp[ss+1][0..seido]] if key split25d(key) za1 = @z1 za2 = @z2 end #if #2つめの頂点 key = d25moji[lgly + q + tmp[ss+2][0..seido] + q + tmp[ss+3][0..seido]] if key split25d(d25moji[lgly + q + tmp[ss+2][0..seido] + q + tmp[ss+3][0..seido]]) if d25moji.length>0 zb1 = @z1 zb2 = @z2 end #if end #if #// lh適用 if za1.nil? && za2.nil? za1 = lh_ly1[lgly] za2 = lh_ly2[lgly] end#if if zb1.nil? && zb2.nil? zb1 = lh_ly1[lgly] zb2 = lh_ly2[lgly] end#if za1t=za1.to_f zb1t=zb1.to_f pt = [] pt<<[x1,y1,za1t+lv] pt<<[x1,y1,za2+lv] if za2 pt<<[x2,y2,zb2+lv] if zb2 pt<<[x2,y2,zb1t+lv] #線または面生成 if pt.length == 2#単独高さが両端にあった場合(1/9) @gr[lyn].entities.add_line pt elsif lt_ == "lt1" || l[0..2] == "sl " #実線か線形ソリッドの時は面を張る face = @gr[lyn].entities.add_face pt face.material = mat_name face.back_material = mat_name elsif pt.length == 3 line = @gr[lyn].entities.add_line [pt[0], pt[1]] line = @gr[lyn].entities.add_line [pt[1], pt[2]] line = @gr[lyn].entities.add_line [pt[2], pt[1]] elsif pt.length == 4 line = @gr[lyn].entities.add_line [pt[0], pt[1]] line = @gr[lyn].entities.add_line [pt[1], pt[2]] line = @gr[lyn].entities.add_line [pt[2], pt[3]] line = @gr[lyn].entities.add_line [pt[3], pt[0]] end #if #//  例外 #点a if za1.nil? if zb2 pt = [] pt<<[x1,y1,za1t+lv] pt<<[x2,y2,zb2+lv] #描いて消す line = @gr[lyn].entities.add_line pt line.erase! end#if end#if #点b if zb1.nil? if za2 pt = [] pt<<[x2,y2,zb1t+lv] pt<<[x1,y1,za2+lv] #描いて消す line = @gr[lyn].entities.add_line pt line.erase! end#if end#if end #if end #if end #while } #/ 円・円弧・円ソリッド取り込み open($rs_jw_path) {|file| while l = file.gets youso_n+=1 break if l[0..3]=="lg0 "#レイヤ定義でbreak lc_ = l[0..2] if l[0..1] == "lc" lt_ = l[0..2] if l[0..1] == "lt" ly_ = l[0..2] if l[0..1] == "ly" lg_ = l[0..2] if l[0..1] == "lg" lgly = lg_+ly_ if lg_ && ly_ lv = lv_lg[lg_]+lv_ly[lg_.to_s+ly_.to_s] cc = l[5..-1].chomp if l[0..4] == "lc10 " lyn = lgly_name[lgly] #補助線出力判断 if $rsjww_lc9_lt9=="No" && (lt_ == "lt9" || lc_ == "lc9") hojo=false else hojo=true end#if #// 円・円弧・円ソリッド(全て楕円は非対応) if (l[0..1] == "ci" && hojo) || l[0..1] == "sc" #/// レイヤ分け model.active_layer = @ly[lyn] if $rsjww_layer_yesno == "Yes" es+=1 tmp = l.split(" ") #/// マテリアル設定 if l[0..1] == "sc" mat_name = mat_list[cc] else mat_name = mat_head + lc_ + lt_ + ly_ if mt.include?(mat_name) == false mt << mat_name mat_list[cc] = mat_name add_color_material(mat_name ,255 ,255 ,255 ,1) end #if end #if #/// 2.5D文字とマッチング za1 = lv za2 = nil sect = (360/$rsjww_cisec.to_f).to_i @sphere = nil #/// 中心座標 key = d25moji[lgly + q + tmp[1][0..seido] + q + tmp[2][0..seido]] if key split25dc(key) za1 = @z1 + lv za2 = @z2 + lv if @z2 sect = @sec if @sec end #if #/// lh適用 if za1==lv && za2==nil za1=lh_ly1[lgly].to_f + lv.to_f za2=lh_ly2[lgly] end#if #// 円・球 if tmp.length == 4 Sketchup.set_status_text("Line.[Ci].sc.Arc " + es.to_s + "/" + (en+yn).to_s) begin if @sphere #球 pt = [tmp[1].to_f.mm,tmp[2].to_f.mm,za1] circle = @gr[lyn].entities.add_circle(pt, z_ax, tmp[3].to_f.mm, sect) face = @gr[lyn].entities.add_face circle face.material = mat_name face.back_material = mat_name face.reverse! if face.normal != z_ax circle = @gr[lyn].entities.add_circle(pt, x_ax, (tmp[3].to_f/2).mm, sect) ball = face.followme circle for ct in circle ct.erase! end for ct in ball if ct.typename=="Edge" ct.soft = true ct.smooth = true end #if end #for elsif za2 #円柱 cigr = Sketchup.active_model.entities.add_group pt = [tmp[1].to_f.mm,tmp[2].to_f.mm,za2] circle = cigr.entities.add_circle(pt, z_ax, tmp[3].to_f.mm, sect) face = cigr.entities.add_face circle face.material = mat_name face.back_material = mat_name face.reverse! if face.normal != z_ax face.pushpull(za1 - za2) #子グループ解除 tr=cigr.transformation gt=@gr[lyn].entities.add_instance(cigr.entities.parent, tr) cigr.erase! gt.explode else #円 cigr = Sketchup.active_model.entities.add_group pt = [tmp[1].to_f.mm,tmp[2].to_f.mm,za1] circle = cigr.entities.add_circle(pt, z_ax, tmp[3].to_f.mm, sect) #子グループ解除 tr=cigr.transformation gt=@gr[lyn].entities.add_instance(cigr.entities.parent, tr) cigr.erase! gt.explode end #if rescue err_mes += "Circle[" + youso_n.to_s + "] " end end #if #// 円ソリッド if l[0..1] == "sc" Sketchup.set_status_text("Line.Ci.[sc].Arc " + es.to_s + "/" + (en+yn).to_s) #多重円は面が貼れない為グループ化 scgr = Sketchup.active_model.entities.add_group pt = [tmp[1].to_f.mm,tmp[2].to_f.mm,za1 ] circle = scgr.entities.add_circle(pt, z_ax, tmp[3].to_f.mm, sect) face = scgr.entities.add_face circle face.material = mat_name face.back_material = mat_name face.reverse! if face.normal != z_ax face.pushpull(za2-za1) if za2 #子グループ解除 tr=scgr.transformation gt=@gr[lyn].entities.add_instance(scgr.entities.parent, tr) scgr.erase! gt.explode end #if #// 円弧 if tmp.length == 8 and l[0..1] == "ci" Sketchup.set_status_text("Line.Ci.sc.[Arc] " + es.to_s + "/" + (en+yn).to_s) pt = [tmp[1].to_f.mm,tmp[2].to_f.mm,za1] deg1 = tmp[4].to_f.degrees + tmp[7].to_f.degrees deg2 = tmp[5].to_f.degrees + tmp[7].to_f.degrees deg2 += Math::PI*2 if deg1 > deg2 begin arc = @gr[lyn].entities.add_arc( pt, x_ax, z_ax, tmp[3].to_f.mm, deg1, deg2 ,sect) #円弧立体化 2017-09-08 if za1 != za2 && za2 mat_name = mat_head + lc_ + lt_ + ly_ n=0 for tmp2 in arc if tmp2.typename=="Edge" n+=1 arc_to_face(za1,za2,tmp2.start,tmp2.end,mat_name,lyn,n) end #if end #for end #if rescue err_mes += "Arc[" + youso_n.to_s + "] " end end #if end #if end #while } #/ 面整理 Sketchup.set_status_text("Erase Edges") planer_edge = [] @gr.each_value do |gtmp| Sketchup.set_status_text("Erase Edges("+gtmp.name+")") for tmp in gtmp.entities if tmp.typename == "Edge" && tmp.faces.length == 2 if tmp.faces[0].material == tmp.faces[1].material && (tmp.faces[0].normal.parallel? tmp.faces[1].normal) planer_edge.push(tmp) end#if end#if end#for end#do for tmp in planer_edge begin tmp.erase! rescue end end #/ 生成可能な面を張る if $rsjww_face_yesno == "Yes" # Yes #find_faceで面を張る @gr.each_value do |gtmp| model.active_layer = @ly[gtmp.name] if $rsjww_layer_yesno == "Yes" for tmp in gtmp.entities tmp.find_faces if tmp.typename == "Edge" end#for end#do #/ モデルと交差 Sketchup.set_status_text("Intersect") @gr.each_value do |gtmp| Sketchup.set_status_text("Intersect("+gtmp.name+")") gtmp.entities.intersect_with(true,[0,0,0],gtmp.entities,[0,0,0],false,gtmp.entities.to_a) end#each #再度find_faceで面を張る @gr.each_value do |gtmp| model.active_layer = @ly[gtmp.name] if $rsjww_layer_yesno == "Yes" for tmp in gtmp.entities tmp.find_faces if tmp.typename == "Edge" end#for end#do end#if #////////////////////////////////////////////////////// #/ 文字 Sketchup.status_text = "Locate 3Dtext." #////////////////////////////////////////////////////// if $rsjww_text_yesno == "Yes" ms = 0 mat = mat_head + "FontColor" if mt.include?(mat) == false add_color_material(mat ,0 ,0 ,0 ,1)#フォント色を黒に設定 end #if #// 標準文字サイズ及びスケール格納 open($rs_jw_path) {|file| while c = file.gets @hs = c.split if c[0..1] == "hs" @hcw = c.split if c[0..2] == "hcw" @hch = c.split if c[0..2] == "hch" @hcd = c.split if c[0..2] == "hcd" if c[0..2] == "hcc" @hcc = c.split break end #if end #while } #// 文字取得 youso_n=0 open($rs_jw_path) {|file| while c = file.gets youso_n+=1 break if c[0..3] == "lg0 "#レイヤ定義でbreak c.chomp! begin#V8,2014 c.encode!("UTF-8", "Shift_JIS", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") rescue end cc = c[2..-1].to_i if c[0..1] == "cc" lg_ = c[0..2] if c[0..1] == "lg" ly_ = c[0..2] if c[0..1] == "ly" lgly = lg_ + ly_ if lg_ && ly_ cn = c[2..-1] if c[0..1] == "cn" && c[2..2] != '"' lv = lv_lg[lg_] + lv_ly[lg_.to_s+ly_.to_s] cnn = cn.to_i if c[0..4] == 'cn"$<' text_font=c[5..-1].split(">")[0]#フォントの装飾"!"と"/"を無視 end #if if c[0..2] == "ch " || c[0..2] == "cv " ||c[0..2] == "cs " ms+=1 Sketchup.set_status_text("Text " + ms.to_s + "/" + mn.to_s) cc = 0 if c[0..2] == "cs " begin#V8,2014 c.force_encoding("utf-8") rescue end tmp = c.split(' ') tmp2 = c.split('"') text = tmp2[1] #任意文字種 if cn[0..0] == "0" cn_tmp = cn.split @hcw[0] = cn_tmp[1] @hch[0] = cn_tmp[2] @hcd[0] = cn_tmp[3] @hcc[0] = cn_tmp[4] end #if if @hcc[cnn] != "9" && tmp2[1].gsub(" ","") != "" && tmp2[1][0..2] != "@BM" && tmp2[1][0..2] != "@TX" && tmp2[1].downcase.index(".skp")==nil #補助文字,画像,テクスチャ定義,コンポファイルは無視 #文字高取得 scale = @hs[lg_[2..2].hex+1].to_i text_h = (@hch[cnn].to_f*scale).mm #文字列全体幅算定 if RUBY_VERSION == "1.8.6" byte = text.length else byte = text.bytesize end #if all = text.split('"').length zenkaku = byte - all hankaku = all - zenkaku w1 = ( zenkaku * @hcw[cnn].to_f + hankaku * @hcw[cnn].to_f / 2 ).mm w2 = ( all - 1 ) * @hcd[cnn].to_f.mm #文字間隔 text_w = ( w1 + w2 ) * scale #3Dtext begin group = @gr[lgly_name[lgly]].entities.add_group group.entities.add_3d_text(text,0, text_font,true, false, text_h, 0.0, 0.0, true) #文字サイズ調整 font_scale = 0.8591#MSフォントのサイズ調整をデフォルト値に font_scale = 0.8998 if text_font.include?("FG") transform = Geom::Transformation.scaling font_scale group.transform!(transform) #基点横調整 if cc == 0 || cc == 3 || cc==6 t_x = tmp[1].to_f.mm end #if if cc == 1 || cc == 4 || cc==7 if RUBY_VERSION=="1.8.6" t_x = tmp[1].to_f.mm - text_w/2 else t_x = tmp[1].to_f.mm - text_w/3 end #if end #if if cc == 2 || cc == 5 || cc==8 t_x = tmp[1].to_f.mm - text_w end #if #基点縦調整 if cc == 0 || cc == 1 || cc==2 t_y = tmp[2].to_f.mm end #if if cc == 3 || cc == 4 || cc==5 t_y = tmp[2].to_f.mm - text_h/2 end #if if cc == 6 || cc == 7 || cc==8 t_y = tmp[2].to_f.mm - text_h end #if point=Geom::Point3d.new t_x , t_y , lv transform = Geom::Transformation.new point,z_ax group.transform!(transform) #角度調整 angl=-Math.atan2(tmp[3].to_f,tmp[4].to_f)+Math.atan2(1,1)*2 transform = Geom::Transformation.rotation [tmp[1].to_f.mm,tmp[2].to_f.mm,lv], z_ax, angl group.transform!(transform) #文字色 group.material = mat if $rsjww_textedge_yesno == "Yes" for tmp in group.entities tmp.hidden = true if tmp.typename == "Edge" end #for end #if rescue err_mes += "3dTextFail[" + youso_n.to_s + "] " end end #if end #if end #while } end #if #////////////////////////////////////////////////////// #/ コンポーネント配置 Sketchup.status_text = "Locate components." #////////////////////////////////////////////////////// err_comps = [] #エラー時のリスト用 comps_prg = 0 #コンポーネントの数 #// スケール線 2016-04-14 dc_x_size=[] dc_y_size=[] #// DC Xサイズ 2016-10-18 dc_x_size_lc = "lc9" dc_x_size_lt = "lt16" #// DC Yサイズ 2016-10-18 dc_y_size_lc = "lc9" dc_y_size_lt = "lt17" #// 回収 open($rs_jw_path) {|file| while l = file.gets lc_tmp=l.chomp if l[0..1]=="lc" lt_tmp=l.chomp if l[0..1]=="lt" #DCXスケール線回収 dc_x_size << l if lc_tmp==dc_x_size_lc && lt_tmp==dc_x_size_lt && l[0..0]==" " #DCYスケール線回収 dc_y_size << l if lc_tmp==dc_y_size_lc && lt_tmp==dc_y_size_lt && l[0..0]==" " end #while } ndx=0 if dc_x_size.length>0 dcx1=[] dcy1=[] dcx2=[] dcy2=[] dcsz=[] for tmp in dc_x_size tt=tmp.split dcx1[ndx]=tt[0].to_f dcy1[ndx]=tt[1].to_f dcx2[ndx]=tt[2].to_f dcy2[ndx]=tt[3].to_f dcsz[ndx]=((dcx1[ndx]-dcx2[ndx])**2+(dcy1[ndx]-dcy2[ndx])**2)**0.5 ndx+=1 end#for end#if ndy=0 if dc_y_size.length>0 ddx1=[] ddy1=[] ddx2=[] ddy2=[] ddsz=[] for tmp in dc_y_size tt=tmp.split ddx1[ndy]=tt[0].to_f ddy1[ndy]=tt[1].to_f ddx2[ndy]=tt[2].to_f ddy2[ndy]=tt[3].to_f ddsz[ndy]=((ddx1[ndy]-ddx2[ndy])**2+(ddy1[ndy]-ddy2[ndy])**2)**0.5 ndy+=1 end#for end#if @entities = model.active_entities.add_group.entities open($rs_jw_path) {|file| while l = file.gets begin#V8,2014 l.encode!("UTF-8", "Shift_JIS", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") rescue end lg_ = l[0..2] if l[0..1] == "lg" ly_ = l[0..2] if l[0..1] == "ly" lgly = lg_ + ly_ if lg_ && ly_ lv = lv_lg[lg_]+lv_ly[lg_.to_s+ly_.to_s] #jwc_temp.txtの文字列だけを検索対象に if l.downcase.index(".skp") #// レイヤ分け model.active_layer = @ly[lgly_name[lgly]] if $rsjww_layer_yesno == "Yes" c = l.split('|') #末尾に「|」で区切られた値がある場合は高さとして格納 tmp = c[0].split('"') #tmpに文字列を格納 tmps = c[0].split(" ") #tmpsに座標を格納 comps_prg += 1 height = 0 comp_path = $rs_comp_path + tmp[1].gsub(/^\^\^|^\~\~|^\#\#|^\%\%|^\@\@|^\*\*/,"").strip comp_path=tmp[1].strip if tmp[1][1..1]==":" comp_path=tmp[1].strip if tmp[1].include?("http") comp_x = tmps[1].to_f comp_y = tmps[2].to_f r1 = tmps[3].to_f r2 = tmps[4].to_f height = c[1].to_f.mm if c[1]!=nil comp_r = Geom::Vector3d.new r1,r2,0 angle = comp_r.angle_between x_ax angle = -angle if r2<0 point = Geom::Point3d.new comp_x/ 25.4,comp_y/ 25.4,height +lv transform = Geom::Transformation.new point,z_ax definitions = model.definitions begin Sketchup.status_text = "Locate components. 9" + comp_path.to_s if comp_path[0..3]=="http" comp = definitions.load_from_url tmp[1].strip else comp = definitions.load comp_path end #if instance = @gr[lgly_name[lgly]].entities.add_instance comp, transform transform = Geom::Transformation.rotation point,z_ax,angle instance.transform!(transform) rescue err_comps << comp_path end end #if end #while } #////////////////////////////////////////////////////// #/ 起し絵 Sketchup.status_text = "Elevationing." #////////////////////////////////////////////////////// #// 起し絵検索 Sketchup.set_status_text("Transform elevations") pn5={} pn6={} l95={} elv={} open($rs_jw_path) {|file| while l = file.gets lg_ = l[0..2] if l[0..1] == "lg" ly_ = l[0..2] if l[0..1] == "ly" lgly = lg_ + ly_ if lg_ && ly_ lv = lv_lg[lg_]+lv_ly[lg_.to_s+ly_.to_s] pn = l if l[0..1]=="pn" lc = l[0..2] if l[0..1] == "lc" lt = l[0..2] if l[0..1] == "lt" if l[0..1]=="pt" if pn[0..2]=="pn6" pn6[lgly]=l.chomp elv[lgly]=lv elsif pn[0..2]=="pn5" pn5[lgly]=l.chomp end#if end#if if l[0..0]==" " && lt=="lt9" && lc=="lc5" l95[lgly]="l" + l.chomp end#if end #while } #//  起し絵 pi=Math.atan2(1, 1)*4 kt=0 pn6.each{|key, value| if pn5[key] #// 平面図基点 t1=value.split ax=t1[1].to_f ay=t1[2].to_f #// 起こし基点 t2=pn5[key].split bx=t2[1].to_f by=t2[2].to_f #「#lv」 if elv[key] z=elv[key].to_f*1000 else z=0 end#if kt+=1 #//   起こす point = Geom::Point3d.new ax/25.4,ay/25.4,z t_val = Geom::Transformation.rotation point,x_ax,pi/2 @gr[lgly_name[key]].transform! t_val #//   回す if l95[key] a=l95[key].split cx=a[1].to_f cy=a[2].to_f dx=a[3].to_f dy=a[4].to_f if bx.to_i==cx.to_i && by.to_i==cy.to_i vec=Geom::Vector3d.new((dx-bx),(dy-by),0) elsif bx.to_i==dx.to_i && by.to_i==dy.to_i vec=Geom::Vector3d.new((cx-bx),(cy-by),0) else vec=x_ax end#if if vec.y>0 angle=vec.angle_between x_ax else angle=-(vec.angle_between x_ax) end#if else angle=0 end#if t_val = Geom::Transformation.rotation point,z_ax,angle @gr[lgly_name[key]].transform! t_val #//   移動 vec=Geom::Vector3d.new((bx-ax).mm,(by-ay).mm,z) t_val = Geom::Transformation.new vec @gr[lgly_name[key]].transform! t_val end#if } #/ 全体をグループ化 if $rsjww_group_yesno == "Yes" @grrsj = Sketchup.active_model.entities.add_group @grrsj.name = 'RSJww_Group' @gr.each_value do |gtmp| begin tr=gtmp.transformation#transformationを回収 gt=@grrsj.entities.add_instance(gtmp.entities.parent, tr) gt.name=gtmp.name gtmp.erase!#親グループに複製追加したので元グループは消去 rescue end #rescue end#each end #if #/ レイヤごとグループ化解除 if $rsjww_ly_group_yesno == "No" if $rsjww_group_yesno == "No" #全体がグループ化されていない時は個別に分解 @gr.each_value do |gtmp| gtmp.explode end#each else #全体がグループ化されている時は親グループ内で分解 for gtmp in @grrsj.entities begin gtmp.explode# if gtmp.typename=="Group" rescue end end#each end#if end #if #/ 終了処理 #/ view = view.zoom_extents#処理後モデル全体範囲でズーミング s = File::mtime($rs_jw_path).strftime('%Y/%m/%d %H:%M:%S') mess = "FileName\n" +$rs_jw_path + "(" + s + ")\n\n" mess += houi_settei mess += "ErrorFace : " + error_face.to_s + "\n\n" if error_face > 0 mess += "ErrorCircle : " + err_ci.to_s + "\n\n" if err_ci > 0 mess += "Errorline : " + err_mes + "\n\n" if err_mes != "" mess += "ErrorComponents\n" + err_comps.uniq!.join("\n").to_s + "\n\n" if err_comps.length > 1 mess += "LoaderrorTexture\n\n" + @TX_err if @TX_err != "" mess += "Total " + (Time.now-start_time).to_s + "sec" UI.messagebox(mess) model.commit_operation end #def #/ ////////// サブ ////////// #// マテリアル登録 def add_color_material(material_name ,r ,g ,b ,alpha) #/// 色マテリアル登録 materials = Sketchup.active_model.materials material = materials.add material_name material.color=Sketchup::Color.new [ r , g , b ] material.alpha = alpha end #def def add_slcolor_material(mat ,slc ,alpha) #/// ソリッド色マテリアル登録 materials = Sketchup.active_model.materials mat_rgb = sprintf("%#08x", slc)[2..-1] m = materials.add mat b = mat_rgb[0..1] g = mat_rgb[2..3] r = mat_rgb[4..5] m.color = Sketchup::Color.new [r.hex,g.hex,b.hex] m.alpha = alpha end #def def arrange_slcolor_material(mat ,slc ,alpha) #/// ソリッド色マテリアル編集 materials = Sketchup.active_model.materials mat_rgb = sprintf("%#08x", slc)[2..-1] b = mat_rgb[0..1] g = mat_rgb[2..3] r = mat_rgb[4..5] materials[mat].color = [r.hex,g.hex,b.hex] materials[mat].texture = "" materials[mat].alpha = alpha end #def #/// テクスチャマテリアル登録 def add_textured_material(material_name ,tx_file ,tx_size ,alpha) materials = Sketchup.active_model.materials if File.exist?(tx_file) material = materials.add material_name material.texture = tx_file material.texture.size = tx_size material.alpha = alpha else add_color_material(material_name ,255 ,128 ,0 ,1) @TX_err += tx_file + "\n" end #if end #def #/// テクスチャマテリアル編集 def arrange_textured_material(mat ,tx_file ,tx_size ,alpha) materials = Sketchup.active_model.materials if File.exist?(tx_file) materials[mat].texture = tx_file materials[mat].texture.size = tx_size materials[mat].alpha = alpha else add_color_material(mat ,255 ,128 ,0 ,1) @TX_err += tx_file + "\n" end #if end #def #// 高さ文字の分割処理 #/// (線) def split25d(h_tmp) if h_tmp.include?(",") a = h_tmp.split(",") @z1 = a[0].to_f.m @z2 = a[1].to_f.m else @z1 = h_tmp.to_f.m @z2 = nil end #if end #def #/// (ソリッド) def split25ds(h_tmp) if h_tmp.include?(",") a = h_tmp.split(",") @z1 = a[0].to_f.m @z2 = a[1].to_f.m else @z1 = h_tmp.to_f.m @z2 = @z1 end #if end #def #/// (円管) def split25de(h_tmp) if h_tmp.include?(",") a = h_tmp.split(",") if a.length>1 @z1 = a[0].to_f.m @zr = a[1].to_f.m if a.length>3 @zs = a[3] else @zs = 0 end #if end #if end #if end #def #/// (角管) def split25dk(h_tmp) if h_tmp.include?(",") a = h_tmp.split(",") if a.length>1 @z1 = a[0].to_f.m @dw = a[1].to_f.m if a.length>2 @dh = a[2].to_f.m else @dh = @dw end #if end #if end #if end #def #/// (円) def split25dc(h_tmp) @sphere = true if h_tmp.include?("g") if h_tmp.include?(",") if @sphere a = h_tmp.chop.split(",") else a = h_tmp.split(",") end #if @z1 = a[0].to_f.m @z2 = a[1].to_f.m if a.length>2 if a[2].to_f != 0 @sec = (360/a[2].to_f).to_i else @sec = (360/$rsjww_cisec.to_f).to_i end #if else @sec = (360/$rsjww_cisec.to_f).to_i end #if else @z1 = h_tmp.to_f.m @z2 = nil @sec = (360/$rsjww_cisec.to_f).to_i end #if end #def #// レイヤセット def set_layer(layer_name) if layer_name model = Sketchup.active_model layers = model.layers if @ly_name.include?(layer_name) == false new_layer = layers.add layer_name @layer_n += 1 @ly_name << layer_name end #unless end #if end #def #// 線を面化 2017-09-08 def add_vertical_square_face_from_2points(z1,z2,p1,p2,mat,lyn) pt=[] pt<<[p1.position.x,p1.position.y,z1] pt<<[p2.position.x,p2.position.y,z1] pt<<[p2.position.x,p2.position.y,z2] pt<<[p1.position.x,p1.position.y,z2] face = @gr[lyn].entities.add_face pt face.material=face.back_material=mat if mat != nil end#def #// 弧を面化 2017-09-09 def arc_to_face(z1,z2,p1,p2,mat,lyn,n) pt=[] pt<<[p1.position.x,p1.position.y,z1] pt<<[p2.position.x,p2.position.y,z1] pt<<[p2.position.x,p2.position.y,z2] pt<<[p1.position.x,p1.position.y,z2] face = @gr[lyn].entities.add_face pt face.material=face.back_material=mat if mat != nil #ソフトニング if n!=1 pt=[] pt<<[p1.position.x,p1.position.y,z1] pt<<[p1.position.x,p1.position.y,z2] edge = @gr[lyn].entities.add_line pt edge.soft = true edge.smooth = true end #if end#def #///////////// SU本体設定 /////////// unless ( file_loaded?("RSjww.rb") ) #ツールバー追加 tb = UI::Toolbar.new("RSjww") cmd = UI::Command.new("Jw_temp.txt取得") { RSjww.new.rs_jw_get } cmd.large_icon = cmd.small_icon = File.dirname(__FILE__) + "/rsico/RSjww.png" cmd.status_bar_text = cmd.tooltip = "Jw_temp.txt取得" tb.add_item cmd tb.show if tb.get_last_state == -1 end if( not file_loaded?("RSjww.rb") ) #Pluginsメニューに追加 UI.menu("Plugins").add_item("RSjww") { rs_jw_get } end file_loaded("RSjww.rb") end #of class #更新履歴 #2018/04/08 コンポーネントのフルパス指定時に存在した不具合を解消した #2018/01/26 batファイルのメッセージから未実行に関する記述を削除した #2018/01/10 高さの設定されていない円弧が全てエラー要素にカウントされていたのを修正した #2017/11/27 「未実行」が出ないようにした #2017/11/27 円管ボールジョイントを修正してダイアログに追加した #2017/09/09 2.5D円弧をスムージングするようにした #2017/09/09 2.5D円弧もレイヤごとグループ分けするようにした #2017/09/09 2.5D円弧が高さゼロに必ず描画されてしまうのを修正した #2017/09/08 アイコン画像を大きくした #2017/09/08 円弧の2.5Dに対応した #2017/07/31 補助線を無視する設定でも円・円弧が変換されていたのを修正した #2017/07/30 グループのエラー処理を追加した #2017/07/29 半角スペースのみの文字を無視するようにした #2017/06/16 「#lv」「#lh」の前に任意の文字列があっても解釈するようにした #2017/04/01 球の指定時に分割角がゼロの場合エラーが起きていたのを修正した #2016/10/18 コンポーネントのXYサイズをスケール線で指定できるようにしたつもりがまだ未実装 #2016/03/01 生成可能な面に張った面のレイヤを分けられるようにした #2016/03/01 実線以外の線の処理がおかしかったのを修正した #2016/02/28 下記グループ化を円・円柱に追加し、子グループを解除するようにした #2016/02/28 円ソリッドを個別に子グループ化してエラーを回避した #2016/02/26 円ソリッドと円の重複でエラーが生じるのを回避した #2016/02/24 #lhの不具合を修正した #2016/02/17 レイヤ名#lhによる高さ設定に対応した(コンポーネントと文字は非対応) #2016/02/13 レイヤ分け指定の時にレイヤ分けされていなかったのを再度修正した #2016/02/09 起こし絵の方向がおかしい場合があったのを修正した #2016/02/03 補助線変換を選択できるようにした #2016/02/03 RSJww_Sample_lv.jwwに球のサンプルを追加した #2016/02/03 V8で球が生成されなかったのを修正した #2016/02/02 同一面上線整理を改善した #2016/02/02 取り込み後のズームを棚上げした #2016/02/02 線の2.5D解釈を調整した #2016/02/01 起し絵に対応した #2016/01/31 テクスチャを10行目でパス指定がある場合にフルパスでも指定できるようにした #2016/01/31 生成可能な部分へ面を張る機能を改善した #2016/01/30 レイヤ分け指定の時にレイヤ分けされていなかったのを修正した #2016/01/29 レイヤ別にグループ化出来るようにした #2016/01/16 面が貼れない時はその要素のみ無視するようにした #2015/12/21 Web上のhttpアドレスで始まる文字列のコンポーネント呼び出しに対応した #2015/12/05 円、円柱、球、円ソリッドの処理を整理した #2015/12/04 エラーレポートを改良した #2015/12/01 2.5D角管データが有るときに2.5D円管データの線が高さゼロで追加されてしまう不具合を解消した #2014/12/30 2.5Dの角管データに一部対応した #2014/12/10 多重円対策を行った(円の高さを乱数で乱すことで対処) #2014/11/25 円の分割角の最後の文字が"g"の時は軸が垂直な真球を描画するようにした #2014/11/21 円の分割角を指定できるようにした #2014/11/17 コンポーネントエラーの完了メッセージを修正した #2014/11/15 2.5D円管の分割角に対応しダイアログで設定できるようにした #2014/11/15 エラーメッセージを整理した #2014/11/05 SU2015でツールバーのアイコンが表示されるように修正した #2014/11/05 太字・斜体指定時にフォントが反映されないのを修正した #2014/11/05 多重円または交差円で必ずエラーが出るので例外処理を追加した #2014/11/04 同名の既存マテリアルがある場合にエラーが出ていたのを修正した #2014/11/03 コンポーネントで#lvが有効でなかったのを修正した #2014/11/03 RSJww_Sample_lv.jwwにlcltly指定マテリアルの解説を追記した #2014/11/02 任意のマテリアルを登録できるようにした #2014/11/01 RSJww.batに「基点指定」と「左下基点」を追加した #2014/11/01 登録するマテリアル名ヘッダを全て「Jw_」に統一した #2014/10/27 任意色ソリッドにテクスチャを貼れるようにした(@TX) #2014/10/26 寸法文字を取り込めるようにした #2014/10/23 レイヤ分けの不具合を修正した #2014/10/22 文字コード周りのバグを修正した2 #2014/10/21 文字コード周りのバグを修正した #2014/10/17 SU2014とSU8で動くように調整した #2014/10/16 レイヤ分けに対応した #2014/10/15 文字を面として取り込めるようにした #2014/10/14 一部の処理を若干高速化した #2014/09/30 円と円ソリッド図形の2.5Dに一部対応した #2014/09/13 高さ文字のマッチング精度を少数3桁に落とした #2014/08/31 円形ソリッドに対応した #2014/06/28 補助線があると鉛直面処理をとばしていたのを修正した #2014/06/15 鉛直面張りの不具合を修正した #2014/06/13 レイヤグループ名とレイヤ名の「#lv」に対応した #2014/05/28 円管データのマテリアル名をlcltly値に戻した #2014/05/25 円管データのマテリアル名にlcltlylg値を与えるようにした #2014/05/22 円管データのマテリアル名にlcltly値を与えるようにした #2014/05/22 2.5Dの円管データに一部対応した #2014/03/21 線の2.5Dで実線以外は立ち上げ時に面を張らないようにした #2014/03/21 線の2.5Dで高さが1つの時にGLから面が張られていた不具合を修正した #2014/03/19 ソリッドRGBのBの値が小さい時に色がおかしくなっていたのを修正した #2014/03/19 線の2.5Dで張る面に線色・線種・レイヤ名によるマテリアルを与えるようにした # ただし処理後に選択して張る面には適用できない #2014/03/19 多角形ソリッドと線形ソリッドの2.5Dに対応した # これによってJWWの2.5Dがプレビューで使えるようになった #2014/03/17 弧の描画を修正した #2014/03/15 線端部の2.5Dに対応した #2014/03/15 JWから取得した文字列をutf8で処理するようにした #2014/03/15 処理後のズームをview.zoom_extentsに変更した #2014/03/15 モデルの交差を一時保留に #2012/12/02 取得した真北角度を表示するようにした #2012/11/16 日影高さのレイヤ読み取り追加 #2012/11/16 真北角度の取得を追加 #2012/11/14 補助線を無視するようにした #2012/11/14 ソリッド端部に日影高さを使ってレベルを設定できるようにした #2012/02/08 グループ化を選択できるようした #2012/02/08 円弧の不具合を解消した #2011/04/09 コンポーネントのエラーメッセージ修正 #2011/04/08 取り込み時に面を張るか否かを選択できるようにした #2011/04/06 数値の取り扱いを整数から実数に変更した #2010/12/06 コンポーネント配置に高さが設定できるようにした #2010/12/05 任意色ソリッドに対応した #2010/02/10 取り込んだモデルにズームするようにした #2010/02/10 取り込み後のメッセージ追加 #2010/02/09 作成開始