tag:blogger.com,1999:blog-34231752482225219302024-03-14T00:06:02.459-07:00S.S.S.S.S.S.S.S. is about collaboration, cooperation and innovation. A community database of things related to scripting, parametric modeling, and digital project.S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comBlogger51125tag:blogger.com,1999:blog-3423175248222521930.post-61373650982760861642009-08-23T21:03:00.000-07:002009-08-24T14:21:37.342-07:00Processing with Class<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pYWndsXyWeQ/SpISlaobKpI/AAAAAAAACpA/Tz1hpoRzQqI/s1600-h/classVine05.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 116px;" src="http://1.bp.blogspot.com/_pYWndsXyWeQ/SpISlaobKpI/AAAAAAAACpA/Tz1hpoRzQqI/s200/classVine05.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5373377739419757202" /></a><br /><br /><br /><br /><br /><br /><br /><span class="Apple-style-span" style="font-family:'trebuchet ms';"><span class="Apple-style-span" style="font-size:small;"><pre><br />//---------------------------------------<br />ArrayList veinpopulation;<br />ArrayList leafpopulation;<br /><br /><span class="Apple-style-span" style="color:#999900;">void setup</span>(){<br /> size(1200, 700);<br /> //background(241);<br /> smooth();<br /> int w = 60;<br /> veinpopulation = new ArrayList();<br /> for( int i=0; i<11; i++ ){<br /> veinpopulation.add( new <span class="Apple-style-span" style="color:#FF9900;">vein</span>( int(random(w, width-w)), int(random(7, 51)) ));<br /> }<br />}<br /><br /><span class="Apple-style-span" style="color:#999900;">void draw</span>(){<br /> background(241);<br /> noLoop();<br /> for( int i=0; i<veinpopulation.size(); i++ ){<br /> vein v = (vein) veinpopulation.get(i);<br /> v.render();<br /> for( int j=0; j<leafpopulation.size(); j++ ){<br /> leaf f = (leaf) leafpopulation.get(j);<br /> f.render();<br /> }<br /> }<br />}<br />//---------------------------------------<br /><br /><br />//---------------------------------------<br /><span class="Apple-style-span" style="color:#FF9900;">class vein</span>{<br /><span class="Apple-style-span" style="color:#999900;">//variables</span><br />int x, leafNum;<br />int strokeColor = color( int(random(150,221)), int(random(71,180)), 0, int(random(69,255)) );<br /><span class="Apple-style-span" style="color:#999900;">//constructor</span><br />vein( int _x, int _leafNum ){<br /> x = _x;<br /> leafNum = _leafNum;<br />}<br /><br /><span class="Apple-style-span" style="color:#999900;">void render</span>(){<br /> strokeWeight(1);<br /> stroke( strokeColor );<br /> line( x, 0, x, height );<br /> int gap = height /leafNum;<br /> int r = int(random(gap));<br /> int direction = 1;<br /> leafpopulation = new ArrayList();<br /> for( int i=0; i<leafNum; i++ ){<br /> int fillColor = color( int(random(150,221)), int(random(71,180)), 0, int(random(69,255)) );<br /> leafpopulation.add( new <span class="Apple-style-span" style="color:#FF9900;">leaf</span>( x, gap*i +r, int(random(7, 41)), direction, fillColor ));<br /> direction = -direction;<br /> }<br />}<br />}<br />//---------------------------------------<br /><br /><br />//---------------------------------------<br /><span class="Apple-style-span" style="color:#FF9900;">class leaf</span>{<br /><span class="Apple-style-span" style="color:#999900;">//variables</span><br />int x, y, leafSize, leafDir, leafSpeed, leafColor;<br /><span class="Apple-style-span" style="color:#999900;">//constructor</span><br />leaf( int _x, int _y, int _leafSize, int _leafDir, int _leafColor ){<br /> x = _x;<br /> y = _y;<br /> leafSize = _leafSize;<br /> leafDir = _leafDir;<br /> leafColor = _leafColor;<br />}<br /><br /><span class="Apple-style-span" style="color:#999900;">void render</span>(){<br /> noStroke();<br /> fill( leafColor );<br /> pushMatrix();<br /> translate(x, y); //move to position<br /> scale( leafSize ); //scale to size<br /> beginShape(); //draw the shape<br /> vertex( leafDir, -0.6875 );<br /> bezierVertex( leafDir, -0.6875, leafDir*0.4375, -1.03125, 0, 0 );<br /> bezierVertex( 0, 0, leafDir, 0.375, leafDir, -0.6875 );<br /> endShape();<br /> popMatrix();<br />}<br />}<br />//---------------------------------------<br /></pre></span></span>yukie hirashimahttp://www.blogger.com/profile/04159422168530372402noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-64099170140247755832009-08-23T20:57:00.000-07:002009-08-24T12:59:11.738-07:00Processing with Function<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pYWndsXyWeQ/SpISrXXpKEI/AAAAAAAACpI/RPf1zJpbDMc/s1600-h/vine18.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 116px;" src="http://3.bp.blogspot.com/_pYWndsXyWeQ/SpISrXXpKEI/AAAAAAAACpI/RPf1zJpbDMc/s200/vine18.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5373377841623279682" /></a><br /><br /><br /><br /><br /><br /><br /><span class="Apple-style-span" style="font-family:'trebuchet ms';"><span class="Apple-style-span" style="font-size:small;"><pre><br />//---------------------------------------<br /><span class="Apple-style-span" style="color:#33CCFF;">void setup</span>(){<br /> size(1200, 700);<br /> smooth();<br /> background(241);<br /> noLoop();<br />}<br /><br /><span class="Apple-style-span" style="color:#33CCFF;">void draw</span>(){<br /> for( int i=0; i<9; i++){<br /> int s = int(random(7, 51));<br /> int w = 2*s;<br /> int n = int(random(9, 51));<br /> <span class="Apple-style-span" style="color:#33CCFF;">drawVine</span>( int(random(w, width-w)), n, s );<br /> }<br />}<br />//---------------------------------------<br /><br /><br />//---------------------------------------<br /><span class="Apple-style-span" style="color:#33CCFF;">void drawVine</span>( int x, int numLeaves, int leafSize ){<br /> strokeWeight(1);<br /> stroke( 0, int(random(0, 71)), int(random(71, 180)));<br /> line( x, 0, x, height );<br /> strokeWeight( 1/leafSize );<br /> int gap = height /numLeaves;<br /> int direction = 1;<br /> for( int i=0; i<numLeaves; i++ ){<br /> int colorR = 0;<br /> int colorG = int(random(0, 71));<br /> int colorB = int(random(71, 180));<br /> noStroke();<br /> fill( colorR, colorG, colorB, random(99, 255) ); //random color for fill<br /> int r = int(random(gap));<br /> <span class="Apple-style-span" style="color:#33CCFF;">drawLeaf</span>( x, gap*i +r, leafSize, direction );<br /> direction = -direction;<br /> }<br />}<br />//---------------------------------------<br /><br /><br />//---------------------------------------<br /><span class="Apple-style-span" style="color:#33CCFF;">void drawLeaf</span>( int x, int y, int size, int dir ){<br /> pushMatrix();<br /> translate(x, y); //move to position<br /> scale(size); //scale to size<br /> beginShape(); //draw the shape<br /> vertex( dir, -0.6875 );<br /> bezierVertex( dir, -0.6875, dir*0.4375, -1.03125, 0, 0 );<br /> bezierVertex( 0, 0, dir, 0.375, dir, -0.6875 );<br /> endShape();<br /> popMatrix();<br />}<br />//---------------------------------------<br /></pre></span></span>yukie hirashimahttp://www.blogger.com/profile/04159422168530372402noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-28575064939187221442009-03-17T23:45:00.000-07:002009-03-17T23:55:49.332-07:00Hexagon Panelization<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_DACBIEbkSBY/ScCZZ4L2qgI/AAAAAAAAANg/X1rRi-O0ypE/s1600-h/ScreenShot183.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 165px;" src="http://4.bp.blogspot.com/_DACBIEbkSBY/ScCZZ4L2qgI/AAAAAAAAANg/X1rRi-O0ypE/s320/ScreenShot183.jpg" alt="" id="BLOGGER_PHOTO_ID_5314416230155069954" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_DACBIEbkSBY/ScCZTpO5SRI/AAAAAAAAANY/OIIBCKyN_qA/s1600-h/000.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 130px;" src="http://2.bp.blogspot.com/_DACBIEbkSBY/ScCZTpO5SRI/AAAAAAAAANY/OIIBCKyN_qA/s200/000.jpg" alt="" id="BLOGGER_PHOTO_ID_5314416123062077714" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_DACBIEbkSBY/ScCZO107QvI/AAAAAAAAANQ/WVhDKANoF3Y/s1600-h/ScreenShot03.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 111px;" src="http://1.bp.blogspot.com/_DACBIEbkSBY/ScCZO107QvI/AAAAAAAAANQ/WVhDKANoF3Y/s200/ScreenShot03.jpg" alt="" id="BLOGGER_PHOTO_ID_5314416040543470322" border="0" /></a><br /><br /><br /><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_DACBIEbkSBY/ScCaeJyrt3I/AAAAAAAAAN4/NzQKCQ3uSy4/s1600-h/ScreenShot01.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 111px;" src="http://2.bp.blogspot.com/_DACBIEbkSBY/ScCaeJyrt3I/AAAAAAAAAN4/NzQKCQ3uSy4/s200/ScreenShot01.jpg" alt="" id="BLOGGER_PHOTO_ID_5314417403112437618" border="0" /></a><br /><br /><br /><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_DACBIEbkSBY/ScCaZjb3sUI/AAAAAAAAANw/5Ga_65Ll-Tw/s1600-h/ScreenShot02.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 111px;" src="http://4.bp.blogspot.com/_DACBIEbkSBY/ScCaZjb3sUI/AAAAAAAAANw/5Ga_65Ll-Tw/s200/ScreenShot02.jpg" alt="" id="BLOGGER_PHOTO_ID_5314417324096729410" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;"><br /><br />Panelization casestydy: Santa Caterina Market.<br /><br />Each panel is flat, leaving slight gap to its neighbors. I started with hexagon-shape grid on surface as in the last image. Six points are identified and stored in array per one panel. Then to produce flat panels, I projected each vector to each normal plane (red). Vector projection is simple VectorAdd method except that I needed to flip the normals (blue) depending on the beginning angle between normals and direct vectors (white) on surface.<br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-3931681193620343022008-10-18T23:29:00.000-07:002008-10-19T00:07:33.037-07:00PowerCopy Automation<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_DACBIEbkSBY/SPrbEK3-LPI/AAAAAAAAAMo/IIvOkzhztw0/s1600-h/instanciation03s.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_DACBIEbkSBY/SPrbEK3-LPI/AAAAAAAAAMo/IIvOkzhztw0/s320/instanciation03s.jpg" alt="" id="BLOGGER_PHOTO_ID_5258756379593551090" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;"><br />Fabric pattern completed via powerCopy Automation. Method is the following three steps →<span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >STEP1. </span></span><span style="color: rgb(204, 204, 255);font-family:trebuchet ms;" ><span style=";font-family:trebuchet ms;font-size:85%;" >BeginInstanceFactory</span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >: to initialize </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >the InstanceFactory with the reference and the document where it is stored. This step must be called once at the beginning whatever the number of instantiations are done.<br /><br /></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >STEP2. </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >It is composed of five methods that must be called in the order. This set of five methods can be called in a loop in order to make several instantiations.<br /><br />a. The method <span style="color: rgb(204, 204, 255);">BeginInstantiate</span>: to initialize all data of the reference.<br />b. The method <span style="color: rgb(204, 204, 255);">PutInputData</span></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >: </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >to set a value to any input.<br />c. The method <span style="color: rgb(204, 204, 255);">GetParameter</span></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >: </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >to retrieve published parameter.<br />d. The method <span style="color: rgb(204, 204, 255);">Instantiate</span></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >: </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="font-weight: bold;"></span>to recreate the reference.<br />e. The method <span style="color: rgb(204, 204, 255);">EndInstantiate</span></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >: </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="font-weight: bold;"> </span>to indicate the instantiation is done.<br /><br />STEP3. <span style="color: rgb(204, 204, 255);">EndInstantiateFactory</span></span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" >: </span></span><span style="font-family:trebuchet ms;"><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="font-weight: bold;"> </span>to end instantiation and cleaning the InstanceFactory. When doing several instantiations in a loop, this step must be called just once at the end of all instantiations.<br /></span></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-53524786380039115962008-10-11T22:44:00.000-07:002008-10-15T07:02:51.067-07:00boundary cone<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_DACBIEbkSBY/SPQsNcwT1xI/AAAAAAAAAMI/iqVbAWcKEP8/s1600-h/boundary_cone.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_DACBIEbkSBY/SPQsNcwT1xI/AAAAAAAAAMI/iqVbAWcKEP8/s200/boundary_cone.jpg" alt="" id="BLOGGER_PHOTO_ID_5256875274616952594" border="0" /></a><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 10/08/2008<br />'compatibility: Rhino4<br />''boundary CONE<br />'----------------------------------------------------------------------------------------------<br />Dim strTrgPt, arrTrgPt<br />strTrgPt = Rhino.GetObject ("select a target point", 1)<br />Dim strALLRefPts<br />strALLRefPts = Rhino.GetObjects ("select reference points", 1)<br />Dim strPtDir, arrPtDir, arrDirVector<br />strPtDir = Rhino.GetObject ("select a point for direction", 1)<br />Dim strRefPts<br />strRefPts = boundaryCone (strTrgPt, strALLRefPts, strPtDir, 400, 30)<br /><br /><span style="color: rgb(153, 153, 0);">'color</span><br />Dim intR, intG, intB<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strRefPts) <br /> intR =255<br /> intG =25+i*Rnd()*2<br /> intB =0 <br /> Call Rhino.ObjectColor (strRefPts(i), RGB(intR, intG, intB)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br />Call Rhino.print("execution completed")<br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> boundaryCone (strTrgPt, strALLRefPts, strPtDir, dblBoundCos, dblBoundAngle)<br />Dim arrResult<br /><br /><span style="color: rgb(153, 153, 0);">'coordinate extraction</span><br />'----------------------------------------------------------------------------------------------<br />Dim arrTrgPt<br />arrTrgPt = Rhino.PointCoordinates (strTrgPt) <br />Dim arrALLRefPts()<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strALLRefPts)<br /> ReDim Preserve arrALLRefPts(i)<br /> arrALLRefPts(i) = Rhino.PointCoordinates (strALLRefPts(i)) <br /><span style="color: rgb(153, 153, 0);">Next</span><br />Dim arrPtDir<br />arrPtDir = Rhino.PointCoordinates (strPtDir) <br /><br /><span style="color: rgb(153, 153, 0);">'set boundary</span><br />'---------------------------------------<br />Dim arrLine1(1), arrLine2(1)<br />Dim dblAngles, dblVectorLength, dblDist<br />Dim arrREFPts(), strRefPts()<br />Dim n, m<br />n = 0 <br /><span style="color: rgb(255, 153, 0);">For</span> m = 0 To UBound(arrALLRefPts) <br /> arrLine1(0) = arrPtDir<br /> arrLine1(1) = arrTrgPt<br /> arrLine2(0) = arrALLRefPts(m)<br /> arrLine2(1) = arrTrgPt<br /> dblAngles = Rhino.Angle2 (arrLine1, arrLine2) <br /> <br /><span style="color: rgb(153, 153, 0);">If</span> dblAngles(0) < dblBoundAngle <span style="color: rgb(153, 153, 0);">Then</span> <br /> dblVectorLength = Rhino.Distance (arrALLRefPts(m), arrTrgPt)<br /> dblDist = dblVectorLength *Cos(dblAngles(0)*2*dblPi/360) <span style="color: rgb(153, 153, 0);">'cone</span> <br /><span style="color: rgb(153, 153, 0);">If</span> dblDist < dblBoundCos <span style="color: rgb(153, 153, 0);">Then</span> <br /> Call Rhino.Print ("through point: " & CStr(n+1)) <br /> ReDim Preserve arrRefPts(n)<br /> arrRefPts(n) = arrALLRefPts(m)<br /> ReDim Preserve strRefPts(n) <br /> strRefPts(n) = strALLRefPts(m) <br /> n = n+1 <br /><span style="color: rgb(153, 153, 0);">End If</span><br /><span style="color: rgb(153, 153, 0);">End If</span> <br /> <br /><span style="color: rgb(255, 153, 0);">Next</span> <br />'---------------------------------------<br />arrResult = strRefPts<br />boundaryCone = arrResult<br /><span style="color: rgb(255, 153, 0);">End Function</span> <br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-26534167595911316152008-10-11T10:42:00.000-07:002008-10-13T22:31:21.612-07:00boundary partial sphere<span style=";font-family:trebuchet ms;font-size:85%;" ><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_DACBIEbkSBY/SPECZWyULII/AAAAAAAAALo/u6ecATPUyjI/s1600-h/boundary_partial+sphere.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_DACBIEbkSBY/SPECZWyULII/AAAAAAAAALo/u6ecATPUyjI/s200/boundary_partial+sphere.jpg" alt="" id="BLOGGER_PHOTO_ID_5255984874754681986" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 10/08/2008<br />'compatibility: Rhino4<br />''boundary PARTIAL SPHERE<br />'----------------------------------------------------------------------------------------------<br />Dim strTrgPt, arrTrgPt<br />strTrgPt = Rhino.GetObject ("select a target point", 1)<br />Dim strALLRefPts<br />strALLRefPts = Rhino.GetObjects ("select reference points", 1)<br />Dim strPtDir, arrPtDir, arrDirVector<br />strPtDir = Rhino.GetObject ("select a point for direction", 1)<br />Dim strRefPts<br />strRefPts = boundaryPartialSphere (strTrgPt, strALLRefPts, strPtDir, 450, 30)<br /><br /><span style="color: rgb(153, 153, 0);">'color</span><br />Dim intR, intG, intB<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strRefPts) <br /> intR =255<br /> intG =25+i*Rnd()*2<br /> intB =0<br /> Call Rhino.ObjectColor (strRefPts(i), RGB(intR, intG, intB)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br />Call Rhino.print("execution completed")<br /> <br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> boundaryPartialSphere (strTrgPt, strALLRefPts, strPtDir, dblBoundR, dblBoundAngle)<br />Dim arrResult<br /><br /><span style="color: rgb(153, 153, 0);">'coordinate extraction</span><br />'---------------------------------------<br />Dim arrTrgPt<br />arrTrgPt = Rhino.PointCoordinates (strTrgPt) <br />Dim arrALLRefPts()<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strALLRefPts)<br /> ReDim Preserve arrALLRefPts(i)<br /> arrALLRefPts(i) = Rhino.PointCoordinates (strALLRefPts(i)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br />Dim arrPtDir<br />arrPtDir = Rhino.PointCoordinates (strPtDir) <br /><br /><span style="color: rgb(153, 153, 0);">'set boundary</span><br />'---------------------------------------<br />Dim dblDist, dblAngles, arrDir<br />Dim arrLine1(1), arrLine2(1)<br />Dim arrREFPts(), strRefPts()<br />Dim n, m<br />n = 0 <br /><span style="color: rgb(255, 153, 0);">For</span> m = 0 To UBound(arrALLRefPts) <br /> dblDist = Rhino.Distance (arrTrgPt, arrALLRefPts(m))<br /><br /><span style="color: rgb(153, 153, 0);">If</span> dblDist < dblBoundR <span style="color: rgb(153, 153, 0);">Then</span> <br /> arrLine1(0) = arrPtDir<br /> arrLine1(1) = arrTrgPt<br /> arrLine2(0) = arrALLRefPts(m)<br /> arrLine2(1) = arrTrgPt <br /> dblAngles = Rhino.Angle2 (arrLine1, arrLine2) <br /><span style="color: rgb(153, 153, 0);">If</span> dblAngles(0) < dblBoundAngle <span style="color: rgb(153, 153, 0);">Then</span> <br /> Call Rhino.Print ("through point: " & CStr(n+1)) <br /> ReDim Preserve arrRefPts(n)<br /> arrRefPts(n) = arrALLRefPts(m)<br /> ReDim Preserve strRefPts(n) <br /> strRefPts(n) = strALLRefPts(m) <br /> n = n+1 <br /><span style="color: rgb(153, 153, 0);">End If</span><br /><span style="color: rgb(153, 153, 0);">End If</span> <br /> <br /><span style="color: rgb(255, 153, 0);">Next</span> <br />'---------------------------------------<br />arrResult = strRefPts<br />boundaryPartialSphere = arrResult<br /><span style="color: rgb(255, 153, 0);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-21997588846948083292008-10-11T10:40:00.000-07:002008-10-13T22:30:06.942-07:00boundary sphere<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_DACBIEbkSBY/SPEBFlSt6HI/AAAAAAAAALY/mwm6_yTeWHs/s1600-h/boundary_sphere.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_DACBIEbkSBY/SPEBFlSt6HI/AAAAAAAAALY/mwm6_yTeWHs/s200/boundary_sphere.jpg" alt="" id="BLOGGER_PHOTO_ID_5255983435539671154" border="0" /></a><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 10/08/2008<br />'compatibility: Rhino4<br />''boundary SPHERE<br />'----------------------------------------------------------------------------------------------<br />Dim strTrgPt<br />strTrgPt = Rhino.GetObject ("select a target point", 1)<br />Dim strALLRefPts<br />strALLRefPts = Rhino.GetObjects ("select reference points", 1)<br />Dim strRefPts<br />strRefPts = boundarySphere (strTrgPt, strALLRefPts, 250)<br /><br /><span style="color: rgb(153, 153, 0);">'color</span><br />Dim intR, intG, intB<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strRefPts)<br /> intR =255<br /> intG =25+i*Rnd()*2<br /> intB =0<br /> Call Rhino.ObjectColor (strRefPts(i), RGB(intR, intG, intB)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br />Call Rhino.print("execution completed")<br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> boundarySphere (strTrgPt, strALLRefPts, dblBoundR)<br />Dim arrResult<br /><br /><br /><span style="color: rgb(153, 153, 0);">'coordinate extraction</span><br />'---------------------------------------<br />Dim arrTrgPt<br />arrTrgPt = Rhino.PointCoordinates (strTrgPt)<br />Dim arrALLRefPts()<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strALLRefPts)<br />ReDim Preserve arrALLRefPts(i)<br />arrALLRefPts(i) = Rhino.PointCoordinates (strALLRefPts(i))<br /><span style="color: rgb(255, 153, 0);">Next</span><br /><br /><br /><span style="color: rgb(153, 153, 0);">'set boundary</span><br />'---------------------------------------<br />Dim dblDist, arrREFPts(), strRefPts()<br />Dim n, m<br />n = 0<br /><span style="color: rgb(255, 153, 0);">For</span> m = 0 To UBound(arrALLRefPts)<br />dblDist = Rhino.Distance (arrTrgPt, arrALLRefPts(m))<br /><br /><span style="color: rgb(153, 153, 0);">If</span> dblDist < dblBoundR <span style="color: rgb(153, 153, 0);">Then</span> <br /> Call Rhino.Print ("through point: " & CStr(n+1))<br /> ReDim Preserve arrRefPts(n)<br /> arrRefPts(n) = arrALLRefPts(m)<br /> ReDim Preserve strRefPts(n)<br /> strRefPts(n) = strALLRefPts(m) <br /> n = n+1<br /><span style="color: rgb(153, 153, 0);">End If</span> <br /><br /><span style="color: rgb(255, 153, 0);">Next</span><br />'---------------------------------------<br />arrResult = strRefPts<br />boundarySphere = arrResult<br /><span style="color: rgb(255, 153, 0);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-85947865845873082842008-10-11T10:38:00.000-07:002008-10-11T12:16:53.056-07:00boundary cylinder<span style=";font-family:trebuchet ms;font-size:85%;" ><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_DACBIEbkSBY/SPDlsTyYmVI/AAAAAAAAAKw/x_cofQGDueM/s1600-h/boundary_cylinder.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_DACBIEbkSBY/SPDlsTyYmVI/AAAAAAAAAKw/x_cofQGDueM/s200/boundary_cylinder.jpg" alt="" id="BLOGGER_PHOTO_ID_5255953314529974610" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 10/08/2008<br />'compatibility: Rhino4<br />''boundary CYLINDER<br />'----------------------------------------------------------------------------------------------<br />Dim strTrgPt<br />strTrgPt = Rhino.GetObject ("select a target point", 1)<br />Dim strALLRefPts<br />strALLRefPts = Rhino.GetObjects ("select reference points", 1)<br />Dim strRefPts<br />strRefPts = <span style="color: rgb(255, 153, 0);">boundaryCylinder</span> (strTrgPt, strALLRefPts, 200, 400)<br /><br /><span style="color: rgb(153, 153, 0);">'color</span><br />Dim intR, intG, intB<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strRefPts) <br /> intR =255<br /> intG =25+i*Rnd()*2<br /> intB =0<br /> Call Rhino.ObjectColor (strRefPts(i), RGB(intR, intG, intB)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br />Call Rhino.print("execution completed")<br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> boundaryCylinder (strTrgPt, strALLRefPts, dblBoundR, dblBoundZ)<br />Dim arrResult<br /><br /><span style="color: rgb(153, 153, 0);">'coordinate extraction</span><br />'---------------------------------------<br />Dim arrTrgPt<br />arrTrgPt = Rhino.PointCoordinates (strTrgPt) <br />Dim arrALLRefPts()<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strALLRefPts)<br /> ReDim Preserve arrALLRefPts(i)<br /> arrALLRefPts(i) = Rhino.PointCoordinates (strALLRefPts(i)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br /><br /><span style="color: rgb(153, 153, 0);">'set boundary</span><br />'---------------------------------------<br />Dim arrFlatPt, arrFlatRefPt, dblDist, dblmaxZ, dblminZ<br />Dim arrREFPts(), strRefPts()<br />dblmaxZ = arrTrgPt(2) + dblBoundZ<br />dblminZ = arrTrgPt(2)<br /> <br />Dim n, m<br />n = 0 <br /><span style="color: rgb(255, 153, 0);">For</span> m = 0 To UBound(arrALLRefPts) <br /> arrFlatPt = Array(arrTrgPt(0), arrTrgPt(1), 0) <br /> arrFlatRefPt = Array(arrALLRefPts(m)(0),arrALLRefPts(m)(1), 0)<br /> dblDist = Rhino.Distance (arrFlatPt, arrFlatRefPt) <br /><span style="color: rgb(153, 153, 0);">If</span> dblDist < dblBoundR <span style="color: rgb(153, 153, 0);">Then</span><br /><span style="color: rgb(153, 153, 0);">If</span> dblmaxZ>arrALLRefPts(m)(2) And arrALLRefPts(m)(2)>dblminZ <span style="color: rgb(153, 153, 0);">Then</span><br /> <br /> Call Rhino.Print ("through point: " & CStr(n+1))<br /> ReDim Preserve arrRefPts(n)<br /> arrRefPts(n) = arrALLRefPts(m)<br /> ReDim Preserve strRefPts(n) <br /> strRefPts(n) = strALLRefPts(m) <br /> n = n+1<br /> <br /><span style="color: rgb(153, 153, 0);">End If</span> <br /><span style="color: rgb(153, 153, 0);">End If</span> <br /><span style="color: rgb(255, 153, 0);">Next</span> <br />'---------------------------------------<br />arrResult = strRefPts<br />boundaryCylinder = arrResult<br /><span style="color: rgb(255, 153, 0);">End Function</span> <br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-3637020846997007792008-10-11T10:35:00.001-07:002008-10-11T12:32:10.529-07:00bounday cube<span style="font-size:85%;"><a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_DACBIEbkSBY/SPDtYHNnzbI/AAAAAAAAALQ/JpYYZavIj_U/s1600-h/boundary_cube.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_DACBIEbkSBY/SPDtYHNnzbI/AAAAAAAAALQ/JpYYZavIj_U/s200/boundary_cube.jpg" alt="" id="BLOGGER_PHOTO_ID_5255961763650194866" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 10/08/2008<br />'compatibility: Rhino4<br />''boundary CUBE<br />'----------------------------------------------------------------------------------------------<br />Dim strTrgPt<br />strTrgPt = Rhino.GetObject ("select a target point", 1)<br />Dim strALLRefPts<br />strALLRefPts = Rhino.GetObjects ("select reference points", 1)<br />Dim strRefPts<br />strRefPts = boundaryCube (strTrgPt, strALLRefPts, 300, 300, 400)<br /><br /><span style="color: rgb(255, 153, 0);">'color</span><br />Dim intR, intG, intB<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strRefPts) <br /> intR =255<br /> intG =25+i*Rnd()*2<br /> intB =0 <br /> Call Rhino.ObjectColor (strRefPts(i), RGB(intR, intG, intB)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br />Call Rhino.print("execution completed")<br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> boundaryCube (strTrgPt, strALLRefPts, dblBoundX, dblBoundY, dblBoundZ)<br />Dim arrResult<br /><br /><span style="color: rgb(153, 153, 0);">'coordinate extraction</span><br />'---------------------------------------<br />Dim arrTrgPt<br />arrTrgPt = Rhino.PointCoordinates (strTrgPt) <br />Dim arrALLRefPts()<br />Dim i<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(strALLRefPts)<br /> ReDim Preserve arrALLRefPts(i)<br /> arrALLRefPts(i) = Rhino.PointCoordinates (strALLRefPts(i)) <br /><span style="color: rgb(255, 153, 0);">Next</span><br /><br /><span style="color: rgb(153, 153, 0);">'set boundary</span><br />'---------------------------------------<br />Dim dblmaxX, dblminX, dblmaxY, dblminY, dblmaxZ, dblminZ<br />Dim arrREFPts(), strRefPts()<br />dblmaxX = arrTrgPt(0) +(dblBoundX/2)<br />dblminX = arrTrgPt(0) -(dblBoundX/2)<br />dblmaxY = arrTrgPt(1) +(dblBoundY/2)<br />dblminY = arrTrgPt(1) -(dblBoundY/2)<br />dblmaxZ = arrTrgPt(2) +(dblBoundZ/2)<br />dblminZ = arrTrgPt(2) -(dblBoundZ/2)<br /> <br />Dim n, m<br />n = 0 <br /><span style="color: rgb(255, 153, 0);">For</span> m = 0 To UBound(arrALLRefPts) <br /><span style="color: rgb(153, 153, 0);">If</span> dblmaxX>arrALLRefPts(m)(0) And arrALLRefPts(m)(0)>dblminX <span style="color: rgb(153, 153, 0);">Then</span><br /><span style="color: rgb(153, 153, 0);">If</span> dblmaxY>arrALLRefPts(m)(1) And arrALLRefPts(m)(1)>dblminY <span style="color: rgb(153, 153, 0);">Then</span><br /><span style="color: rgb(153, 153, 0);">If</span> dblmaxZ>arrALLRefPts(m)(2) And arrALLRefPts(m)(2)>dblminZ <span style="color: rgb(153, 153, 0);">Then</span><br /> <br /> Call Rhino.Print ("through point: " & CStr(n+1))<br /> ReDim Preserve arrRefPts(n)<br /> arrRefPts(n) = arrALLRefPts(m)<br /> ReDim Preserve strRefPts(n) <br /> strRefPts(n) = strALLRefPts(m) <br /> n = n+1<br /> <br /><span style="color: rgb(153, 153, 0);">End If</span><br /><span style="color: rgb(153, 153, 0);">End If</span> <br /><span style="color: rgb(153, 153, 0);">End If</span> <br /><span style="color: rgb(255, 153, 0);">Next</span><br />'---------------------------------------<br />arrResult = strRefPts<br />boundaryCube = arrResult<br /><span style="color: rgb(255, 153, 0);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-47677458516570414972008-09-28T09:51:00.000-07:002008-10-11T21:03:28.151-07:00makeTree Revision<span style=";font-family:trebuchet ms;font-size:85%;" ><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_DACBIEbkSBY/SPFq4UVVZXI/AAAAAAAAAMA/XjQRGxCEMIc/s1600-h/ScreenShot103.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_DACBIEbkSBY/SPFq4UVVZXI/AAAAAAAAAMA/XjQRGxCEMIc/s200/ScreenShot103.jpg" alt="" id="BLOGGER_PHOTO_ID_5256099755881489778" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 08/10/03<br />'compatibility: Rhino4<br />''branching using vector<br /><br /><span style="color: rgb(102, 255, 255);">'first things first...</span><br />'----------------------------------------------------------------------------------------------<br />Dim strRtPts<br />strRtPts = Rhino.GetObjects ("select root points", 1)<br />Call Rhino.AddLayer ("ptCloudRT", RGB(0,0,0)) 'black<br />Call Rhino.ObjectLayer (strRtPts, "ptCloudRT")<br />Dim strALLREFPts<br />strALLREFPts = Rhino.GetObjects ("select reference points", 1)<br />Call Rhino.AddLayer ("ptCloudREF", RGB(105,105,105)) 'gray<br />Call Rhino.ObjectLayer (strALLREFPts, "ptCloudREF")<br />Dim dblNumber<br />dblNumber = 7 '4<br />Dim dblBoundary<br />dblBoundary = 100 '100<br />Call Rhino.Print ("minimize rhino window")<br /><br /><span style="color: rgb(102, 255, 255);">'call function</span><br />Dim arrResultBranchs<br />arrResultBranchs = branch (strRtPts, strALLREFPts, dblNumber, dblBoundary)<br /><br />Dim arrResultTrees, i, j<br /><span style="color: rgb(51, 204, 255);">For</span> j = 0 To UBound(arrResultBranchs)<br /> <span style="color: rgb(102, 255, 255);">'call function</span><br /> ReDim Preserve arrResultTrees(j)<br /> arrResultTrees(j) = tree (20, arrResultBranchs(j))<br /> Dim arrResult01, arrResult02, dblS, dblT<br /><br /> If dblNumber Mod 2 = 1 Then<br /> dblS = dblNumber/2+0.5<br /> dblT = dblNumber-dblS <br /> Else<br /> dblS = dblNumber/2<br /> dblT = dblNumber/2<br /> End If<br /><br /> ReDim arrResult01(dblS-1)<br /> ReDim arrResult02(dblT-1) <br /> Rhino.print("dblS = " & CStr(dblS))<br /> Rhino.print("dblT = " & CStr(dblT))<br /> For i = 0 To (dblS-1)<br /> arrResult01(i) = arrResultTrees(j)(i)<br /> Next<br /> For i = 0 To (dblT-1)<br /> arrResult02(i) = arrResultTrees(j)(i+dblS)<br /> Next<br /><br /><span style="color: rgb(102, 255, 255);">'call function</span><br /> Call tree (10, arrResult01)<br /> Call tree (10, arrResult02)<br /><span style="color: rgb(51, 204, 255);">Next</span><br />Call Rhino.print("execution completed")<br /><br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(51, 204, 255);">Function</span> branch (strRtPts, strALLREFPts, dblNumber, dblBoundary)<br /><a href="http://ssssociety.blogspot.com/2008/09/makebranch-revision.html">refer branch function</a><br /><span style="color: rgb(51, 204, 255);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(51, 204, 255);">Function</span> tree (dblStemLength, arrBranches)<br />Dim arrResult()<br /><br /><span style="color: rgb(102, 255, 255);">'length of given branches</span><br />'---------------------------------------<br />Dim i<br />Dim blnFlag<br />blnFlag = False<br /><br /><span style="color: rgb(51, 204, 255);">For</span> i=0 To UBound(arrBranches) <br /> Dim dblCurveLength<br /> dblCurveLength = Rhino.CurveLength (arrBranches(i))<br /> Call Rhino.print("length = "& CStr(dblCurveLength)) <br /> If dblCurveLength > dblStemLength Then<br /> blnFlag = True<br /> End If<br /><span style="color: rgb(51, 204, 255);">Next</span><br /><br /><span style="color: rgb(102, 255, 255);">'get average if branches are too long,</span><br />'---------------------------------------<br />If blnFlag Then <br /> Rhino.print("blnFlag = true")<br /> Dim arrEdPt, arrStPt<br /> Dim arrAvgPt(2), dblX, dblY, dblZ<br /> dblX = 0<br /> dblY = 0<br /> dblZ = 0<br /><span style="color: rgb(51, 204, 255);">For</span> i = 0 To UBound(arrBranches)<br /> arrEdPt = Rhino.CurveEndPoint (arrBranches(i))<br /> dblX = dblX + arrEdPt(0)<br /> dblY = dblY + arrEdPt(1)<br /> dblZ = dblZ + arrEdPt(2) <br /><span style="color: rgb(51, 204, 255);">Next</span><br /><br /> arrAvgPt(0) = dblX /(UBound(arrBranches)+1)<br /> arrAvgPt(1) = dblY /(UBound(arrBranches)+1)<br /> arrAvgPt(2) = dblZ /(UBound(arrBranches)+1)<br /> arrStPt = Rhino.CurveStartPoint (arrBranches(0))<br /> Dim arrDiff<br /> arrDiff = Rhino.VectorSubtract (arrAvgPt, arrStPt)<br /> Dim dblDiff<br /> dblDiff = Rhino.VectorLength (arrDiff)<br /> Dim k<br /> k = dblStemLength / dblDiff<br /> arrDiff = Rhino.VectorScale (arrDiff, k)<br /> Dim arrSeed<br /> arrSeed = Rhino.VectorAdd (arrStPt, arrDiff)<br /> <br /><span style="color: rgb(102, 255, 255);">'shorter branches</span><br />'---------------------------------------<br /> Dim strNewBranches<br /> ReDim strNewBranches(UBound(arrBranches))<br /><span style="color: rgb(51, 204, 255);">For</span> i = 0 To UBound(arrBranches) <br /> Dim arrLeaf<br /> arrLeaf = Rhino.CurveEndPoint(arrBranches(i))<br /> Dim strLine<br /> strLine = Rhino.AddLine(arrSeed, arrLeaf) <br /> ReDim Preserve arrResult(i)<br /> arrResult(i) = strLine <br /><span style="color: rgb(51, 204, 255);">Next</span><br /><br /> Dim strStem<br /> strStem = Rhino.AddLine (arrStPt, arrSeed) <br /> Call Rhino.DeleteObjects (arrBranches) <br />Else<br /> Rhino.print("blnFlag = false")<br />End If<br /> '---------------------------------------<br /> <br />Call Rhino.CurrentLayer ("0")<br />tree = arrResult <br /><span style="color: rgb(51, 204, 255);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-35295525708442884192008-09-28T09:31:00.000-07:002008-10-11T20:33:55.488-07:00makeBranch Revision<span style=";font-family:trebuchet ms;font-size:85%;" ><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_DACBIEbkSBY/SPFoVgy00KI/AAAAAAAAAL4/liX1DNLJbTI/s1600-h/branch08.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_DACBIEbkSBY/SPFoVgy00KI/AAAAAAAAAL4/liX1DNLJbTI/s200/branch08.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5256096958907732130" /></a><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 08/10/03<br />'compatibility: Rhino4<br />''branching using vector<br /><br /><span style="color: rgb(153, 153, 0);">'first things first...</span><br />'----------------------------------------------------------------------------------------------<br />Dim strRtPts<br />strRtPts = Rhino.GetObjects ("select root points", 1)<br />Call Rhino.AddLayer ("ptCloudRT", RGB(0,0,0)) 'black<br />Call Rhino.ObjectLayer (strRtPts, "ptCloudRT")<br />Dim strALLREFPts<br />strALLREFPts = Rhino.GetObjects ("select reference points", 1)<br />Call Rhino.AddLayer ("ptCloudREF", RGB(105,105,105)) 'gray<br />Call Rhino.ObjectLayer (strALLREFPts, "ptCloudREF")<br />Dim dblNumber<br />dblNumber = 8 '4<br />Dim dblBoundary<br />dblBoundary = 100 '100<br />Call Rhino.Print ("minimize rhino window")<br /><br />Call branch (strRtPts, strALLREFPts, dblNumber, dblBoundary)<br />Call Rhino.print("execution completed")<br /><br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> branch (strRtPts, strALLREFPts, dblNumber, dblBoundary)<br />Dim arrResult()<br /><br /><span style="color: rgb(153, 153, 0);">'coordinate extraction</span><br />'----------------------------------------------------------------------------------------------<br />Dim i, arrRtPts(), arrALLREFPts()<br />For i = 0 To UBound(strRtPts)<br /> ReDim Preserve arrRtPts(i)<br /> arrRtPts(i) = Rhino.PointCoordinates (strRtPts(i)) <br />Next<br />For i = 0 To UBound(strALLREFPts)<br /> ReDim Preserve arrALLREFPts(i)<br /> arrALLREFPts(i) = Rhino.PointCoordinates (strALLREFPts(i)) <br />Next<br /><br /><span style="color: rgb(153, 153, 0);">'for each RootPoint,</span><br />'----------------------------------------------------------------------------------------------<br />Dim dblmaxX, dblminX, dblmaxY, dblminY<br />Dim arrREFPts(), arrMinLength(), dblMinLength<br />Dim strShortests()<br />Dim j<br /><span style="color: rgb(255, 153, 0);">For</span> j = 0 To UBound(arrRtPts) <br /> Call Rhino.Print ("Round " & CStr(j+1))<br /> <br /><span style="color: rgb(153, 153, 0);">'set boundary</span><br /> '---------------------------------------<br /> dblmaxX = arrRtPts(j)(0) +dblBoundary <br /> dblminX = arrRtPts(j)(0) -dblBoundary <br /> dblmaxY = arrRtPts(j)(1) +dblBoundary <br /> dblminY = arrRtPts(j)(1) -dblBoundary <br /> Dim n, m<br /> n = 0 <br /><span style="color: rgb(255, 153, 0);">For</span> m = 0 To UBound(arrALLREFPts) <br /> If dblmaxX>arrALLREFPts(m)(0) And arrALLREFPts(m)(0)>dblminX And dblmaxY>arrALLREFPts(m)(1) And arrALLREFPts(m)(1)>dblminY Then<br /> ReDim Preserve arrREFPts(n)<br /> arrREFPts(n) = arrALLREFPts(m) <br /> n = n+1 <br /> End If <br /><span style="color: rgb(255, 153, 0);">Next</span> <br /> '---------------------------------------<br /> <br /> <br /><span style="color: rgb(153, 153, 0);">'find dblNumber shortest</span><br /> '---------------------------------------<br /> Dim arrVectorTemp, dblLengthTemp<br /> Dim arrVector01, dblLength01<br /> Dim arrPrevShortest, dblPrevShortest<br /> Dim arrCurrShortest, dblCurrShortest <br /> dblMinLength = 0 <br /><br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To dblNumber-1 <br /><span style="color: rgb(153, 153, 0);">'make one to begin comparison with</span> <br /> arrVectorTemp = Rhino.VectorCreate (arrREFPts(0), arrRtPts(j))<br /> dblLengthTemp = Rhino.VectorLength (arrVectorTemp) <br /> arrPrevShortest = arrVectorTemp<br /> dblPrevShortest = dblLengthTemp<br /> <br /> If dblPrevShortest <= dblMinLength Then<br /> dblPrevShortest = dblPrevShortest * 100<br /> End If <br /> <br /><span style="color: rgb(255, 153, 0);">For</span> n = 0 To UBound(arrREFPts)<br /> arrVector01 = Rhino.VectorCreate (arrREFPts(n), arrRtPts(j))<br /> dblLength01 = Rhino.VectorLength (arrVector01) <br /> <br /> If dblLength01 <= dblPrevShortest And dblLength01 > dblMinLength Then<br /> arrCurrShortest = arrVector01<br /> dblCurrShortest = dblLength01 <br /> Else <br /> arrCurrShortest = arrPrevShortest<br /> dblCurrShortest = dblPrevShortest <br /> End If<br /> <br /><span style="color: rgb(153, 153, 0);">'prepare for next round</span><br /> arrPrevShortest = arrCurrShortest<br /> dblPrevShortest = dblCurrShortest <br /> <br /><span style="color: rgb(255, 153, 0);">Next</span> 'arrREFPts<br /> ReDim Preserve arrMinLength(i)<br /> arrMinLength(i) = arrCurrShortest <br /> dblMinLength = dblCurrShortest <br /> Call Rhino.Print (CStr(i+1) & " shortest:" & " " & CStr(dblMinLength))<br /> <br /> Call Rhino.AddLayer (CStr(i+1) & " shortest", RGB(255-i*20, 50+i*24, 0)) <br /> Call Rhino.CurrentLayer (CStr(i+1) & " shortest")<br /> <br /> ReDim Preserve strShortests(i) <br /> strShortests(i) = Rhino.Addline (arrRtPts(j), Rhino.VectorAdd (arrRtPts(j), arrMinLength(i)))<br /> <br /><span style="color: rgb(255, 153, 0);">Next</span> 'i<br /> ReDim Preserve arrResult(j)<br /> arrResult(j) = strShortests<br /> '--------------------------------------- <br /><span style="color: rgb(255, 153, 0);">Next</span> 'j<br /><br />Call Rhino.CurrentLayer ("0") <br />branch = arrResult<br /><span style="color: rgb(255, 153, 0);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-3000208568447799392008-09-28T08:16:00.000-07:002008-10-13T23:06:29.784-07:00makeBridge Revision<span style=";font-family:trebuchet ms;font-size:85%;" ><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_DACBIEbkSBY/SPFkmY_fXVI/AAAAAAAAALw/Ht2ZNHLIqjM/s1600-h/bridge03.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_DACBIEbkSBY/SPFkmY_fXVI/AAAAAAAAALw/Ht2ZNHLIqjM/s200/bridge03.jpg" alt="" id="BLOGGER_PHOTO_ID_5256092850824633682" border="0" /></a><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 08/10/03<br />'compatibility: Rhino4<br />''draw normal at each division point using vector<br />''then create bridge structure<br /><br /><br /><span style="color: rgb(153, 153, 0);">'first things first...</span><br />'----------------------------------------------------------------------------------------------<br />Call Rhino.AddLayer ("splineCenter", RGB(255,0,0)) 'black<br />Call Rhino.AddLayer ("centerPt", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("normalAxis", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("normal01", RGB(255,161,0)) 'gold<br />Call Rhino.AddLayer ("normal02", RGB(255,127,0)) 'orange<br />Call Rhino.AddLayer ("side01", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("side02", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("Pt", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("Line011", RGB(63,191,191)) 'turquoise<br />Call Rhino.AddLayer ("Line022", RGB(63,191,191)) 'turquoise<br />Call Rhino.AddLayer ("Line033", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("Line044", RGB(0,0,0)) 'black<br />Call Rhino.AddLayer ("Line055", RGB(255,0,0)) 'red<br /><br />Dim strSpline<br />strSpline = Rhino.GetObject ("select a spline curve", 4)<br />Call Rhino.ObjectLayer (strSpline , "splineCenter")<br />Call Rhino.LayerVisible ("splineCenter", False)<br />Dim dblsegLength<br />dblsegLength = 1500 '1500<br />Dim dblWidth<br />dblWidth = 2000 '2000<br />Dim dblSideAngle<br />dblSideAngle = 100 '100<br />Dim dblSideHeight<br />dblSideHeight = 900 '900<br />Dim dblDiagLength<br />dblDiagLength = dblSideHeight*Sec(dblSideAngle-90)<br />Call Rhino.Print (dblDiagLength) '913.884<br /><br />Function Sec(x)<br />Dim dblPi<br />dblPi = Rhino.Pi<br />Sec = 1 / Cos(x*2*dblPi/360)<br />End Function<br /><br />Call ribaBridge (strSpline, dblSegLength, dblWidth, dblSideAngle, dblDiagLength)<br />Call Rhino.print("execution completed")<br /><br /><br /><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /><span style="color: rgb(255, 153, 0);">Function</span> ribaBridge (strSpline, dblSegLength, dblWidth, dblSideAngle, dblDiagLength)<br /><br /><span style="color: rgb(153, 153, 0);">'division points</span><br />'---------------------------------------<br />Dim arrCenPts, strCenPt<br />Dim a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z<br /><br />If Rhino.IsCurve(strSpline) Then<br /> 'by length segment<br /> arrCenPts = Rhino.DivideCurveLength(strSpline, dblSegLength)<br />'by segments<br />'intSegments = 130<br />'arrPoints = Rhino.DivideCurve(strSpline, intSegments)<br /> Call Rhino.CurrentLayer ("centerPt")<br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(arrCenPts)<br /> strCenPt = Rhino.AddPoint (arrCenPts(i))<br /><span style="color: rgb(255, 153, 0);">Next</span><br />End If<br /><br /><span style="color: rgb(153, 153, 0);">'normal</span><br />'---------------------------------------<br />Dim dblParam, arrTangents(), arrNormals()<br />Dim strNormalSides01(), strNormalSides02()<br /><br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(arrCenPts)<br />dblParam = Rhino.CurveClosestPoint(strSpline, arrCenPts(i))<br />ReDim Preserve arrTangents(i)<br />arrTangents(i) = Rhino.CurveTangent(strSpline, dblParam)<br />ReDim Preserve arrNormals(i)<br />arrNormals(i) = Rhino.VectorCrossProduct(arrTangents(i), Array(0,0,1))<br />ReDim Preserve arrNormals(i)<br />arrNormals(i) = Rhino.VectorUnitize(arrNormals(i))<br />ReDim Preserve arrNormals(i)<br />arrNormals(i) = Rhino.VectorScale(arrNormals(i), dblWidth)<br /><br />Call Rhino.CurrentLayer ("normal01")<br />ReDim Preserve strNormalSides01(i)<br />strNormalSides01(i) = Rhino.addLine(arrCenPts(i), Rhino.VectorAdd(arrCenPts(i), arrNormals(i)))<br />ReDim Preserve strNormalSides02(i)<br />strNormalSides02(i) = Rhino.RotateObject (strNormalSides01(i), arrCenPts(i), 180, Array(0,0,1), True)<br />Call Rhino.ObjectLayer (strNormalSides02(i), "normal02")<br /><span style="color: rgb(255, 153, 0);">Next</span><br /><br /><span style="color: rgb(153, 153, 0);">'prepare vector for 3d rotation</span><br />'---------------------------------------<br />Dim arrAxiss(), arrSides(), dilDiagLength(), strSides01, strSides02<br />Dim arrSides01EdPts(), arrSides02EdPts()<br />Dim arrSides01TpPts(), arrSides02TpPts()<br /><br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(arrCenPts)<br />ReDim Preserve arrSides01EdPts(i)<br />arrSides01EdPts(i) = Rhino.CurveEndPoint (strNormalSides01(i))<br />ReDim Preserve arrSides02EdPts(i)<br />arrSides02EdPts(i) = Rhino.CurveEndPoint (strNormalSides02(i))<br /><br />ReDim Preserve arrAxis(i)<br />arrAxis(i) = Rhino.VectorRotate (arrNormals(i), -90, Array(0,0,1))<br />ReDim Preserve arrSides(i)<br />arrSides(i) = Rhino.VectorRotate (arrNormals(i), 180-dblSideAngle, arrAxis(i))<br />ReDim Preserve arrSides(i)<br />arrSides(i) = Rhino.VectorUnitize (arrSides(i))<br />ReDim Preserve arrSides(i)<br />arrSides(i) = Rhino.VectorScale (arrSides(i), dblDiagLength)<br /><br />Call Rhino.CurrentLayer ("side01")<br />strSides01 = Rhino.addLine (arrSides01EdPts(i), Rhino.VectorAdd(arrSides01EdPts(i), arrSides(i)))<br />ReDim Preserve arrSides(i)<br />arrSides(i) = Rhino.VectorRotate (arrSides(i), (dblSideAngle-90)*2, arrAxis(i))<br />Call Rhino.CurrentLayer ("side02")<br />strSides02 = Rhino.addLine (arrSides02EdPts(i), Rhino.VectorAdd(arrSides02EdPts(i), arrSides(i)))<br /><br /><span style="color: rgb(153, 153, 0);">'add points</span><br />ReDim Preserve arrSides01TpPts(i)<br />arrSides01TpPts(i) = Rhino.CurveEndPoint (strSides01)<br />ReDim Preserve arrSides02TpPts(i)<br />arrSides02TpPts(i) = Rhino.CurveEndPoint (strSides02)<br /><br />Call Rhino.CurrentLayer ("Pt")<br />Call Rhino.AddPoint (arrSides01EdPts(i))<br />Call Rhino.AddPoint (arrSides02EdPts(i))<br />Call Rhino.AddPoint (arrSides01TpPts(i))<br />Call Rhino.AddPoint (arrSides02TpPts(i))<br /><span style="color: rgb(255, 153, 0);">Next</span><br /> <br /><span style="color: rgb(153, 153, 0);">'create lines between (i) and (i+1)</span><br />'---------------------------------------<br />Dim strLine011, strLine022, strLine033, strLine044, strLine055<br /><br /><span style="color: rgb(255, 153, 0);">For</span> i = 0 To UBound(arrCenPts)-1<br />Call Rhino.CurrentLayer ("Line011")<br />strLine011 = Rhino.AddLine (arrSides01EdPts(i), arrSides01EdPts(i+1))<br />Call Rhino.CurrentLayer ("Line022")<br />strLine022 = Rhino.AddLine (arrSides02EdPts(i), arrSides02EdPts(i+1))<br />Call Rhino.CurrentLayer ("Line033")<br />strLine033 = Rhino.AddLine (arrSides01TpPts(i), arrSides01TpPts(i+1))<br />Call Rhino.CurrentLayer ("Line044")<br />strLine044 = Rhino.AddLine (arrSides02TpPts(i), arrSides02TpPts(i+1))<br />Call Rhino.CurrentLayer ("Line055")<br />strLine055 = Rhino.AddLine (arrCenPts(i), arrCenPts(i+1))<br /><span style="color: rgb(255, 153, 0);">Next</span><br /><br /><span style="color: rgb(255, 153, 0);">End Function</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-12285066205143836252008-08-31T01:14:00.000-07:002008-10-18T23:03:10.451-07:00Beginners Samples<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_DACBIEbkSBY/SPrNgcLGJeI/AAAAAAAAAMg/DYyCI6ePDw8/s1600-h/ScreenShot110.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_DACBIEbkSBY/SPrNgcLGJeI/AAAAAAAAAMg/DYyCI6ePDw8/s200/ScreenShot110.jpg" alt="" id="BLOGGER_PHOTO_ID_5258741472110716386" border="0" /></a><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br />Some useful CATIA vba samples, since v5Automation was overwhelming for newbies like me. </span><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><span style="color: rgb(51, 204, 255);">'opening statement /intersectionPt</span><br />'---------------------------------------<br />Dim partDocument1 As PartDocument<br />Set partDocument1 = CATIA.ActiveDocument<br />Dim part1 As Part<br />Set part1 = partDocument1.Part<br /><span style="color: rgb(51, 255, 255);">'add geom set here</span><br />Dim hybridBody1 As HybridBody<br />Set hybridBody1 = part1.HybridBodies.Add()<br />hybridBody1.Name = "Geometrical Set.New"<br />part1.Update<br /><span style="color: rgb(51, 255, 255);">'used geom set</span><br />Dim hybridBody2 As HybridBody<br />Set hybridBody2 = part1.HybridBodies.Item("Geometrical Set.1")<br />Dim hybridBody3 As HybridBody<br />Set hybridBody3 = part1.HybridBodies.Item("Geometrical Set.2").HybridBodies.Item("Multi Output.1 (Intersect)")<br />'---------------------------------------<br /><br /><br /><span style="color: rgb(51, 204, 255);">'selection set /color</span><br />'---------------------------------------<br />Dim colorCount<br />colorCount = hybridBody1.HybridShapes.Count<br /><span style="color: rgb(51, 255, 255);">For</span> i = 1 To colorCount<br />Call partDocument1.Selection.Add(hybridBody1.HybridShapes.Item(i))<br />Dim visProperties1 As VisPropertySet<br />Set visProperties1 = partDocument1.Selection.VisProperties<br />visProperties1.SetRealColor 255, 255, 0, 1 'yellow(255,255,0)<br />partDocument1.Selection.Clear<br /><span style="color: rgb(51, 255, 255);">Next</span> i<br />'---------------------------------------<br /><br /><br /><span style="color: rgb(51, 204, 255);">'measurable, parameter, formula</span><br />'---------------------------------------<br /><span style="color: rgb(51, 255, 255);">'create line WITHOUT parameter first</span><br />Dim line1 As HybridShapeLineAngle<br />Set line1 = part1.HybridShapeFactory.AddNewLineAngle( , , , , , , , )<br />Dim angleFormula01 As Formula<br />Set angleFormula01 = part1.relations.CreateFormula( , , <span style="color: rgb(51, 255, 255);">line1.Angle</span>, )<br />hybridBody1.AppendHybridShape line1<br />part1.InWorkObject = line1<br /><br />Dim TheMeasurable01 As Measurable<br />Set TheMeasurable01 = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench").GetMeasurable( )<br />Dim lineMeasurable01 As Double<br />lineMeasurable01 = TheMeasurable01.Length<br />Dim MeasurableRealStOff01 As RealParam<br />Set MeasurableRealStOff01 = part1.Parameters.CreateReal("Real.measurable stOff", lineMeasurable01)<br />Dim MeasurableRealEdOff01 As RealParam<br />Set MeasurableRealEdOff01 = part1.Parameters.CreateReal("Real.measurable edOff", lineMeasurable01)<br /><br />Dim lengthFormula011 As Formula<br />Set lengthFormula011 = part1.relations.CreateFormula( , , <span style="color: rgb(51, 255, 255);">line1.BeginOffset</span>, )<br />Dim lengthFormula012 As Formula<br />Set lengthFormula012 = part1.relations.CreateFormula( , , <span style="color: rgb(51, 255, 255);">line1.EndOffset</span>, )<br />'---------------------------------------<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-6869707029139112702008-08-16T16:07:00.001-07:002008-10-18T22:40:05.330-07:00CATIA scripting<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_DACBIEbkSBY/SKdd1IiG7sI/AAAAAAAAAIs/_cTWY9tUq78/s1600-h/VB+editor.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_DACBIEbkSBY/SKdd1IiG7sI/AAAAAAAAAIs/_cTWY9tUq78/s320/VB+editor.jpg" alt="" id="BLOGGER_PHOTO_ID_5235256259246485186" border="0" /></a><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></span><span style="font-family:trebuchet ms;">Finally got hands on CATIA scripting. Most confusing thing about CATIA vba is the tree structure. Within Part Document only, CATIA has the following structure.<br /><br /></span><span style="font-family:trebuchet ms;">+-- </span><span style="font-family:trebuchet ms;"><span>PartDocument</span><br />+-</span><span style="font-family:trebuchet ms;">--</span><span style="font-family:trebuchet ms;">- Part<br />+--</span><span style="font-family:trebuchet ms;">--</span><span style="font-family:trebuchet ms;">-- HybridShapeFactory<br />+---</span><span style="font-family:trebuchet ms;">--</span><span style="font-family:trebuchet ms;">--- HybridBodies<br />+----</span><span style="font-family:trebuchet ms;">--</span><span style="font-family:trebuchet ms;">---- HybridBody<br />+------</span><span style="font-family:trebuchet ms;">--</span><span style="font-family:trebuchet ms;">---- HybridShapes<br />+------</span><span style="font-family:trebuchet ms;">--</span><span style="font-family:trebuchet ms;">------ HybridShape</span><br /><br /><span style="font-family:trebuchet ms;">And also, since CATIA has multiple ways to create a geometry,<br /></span><span style="font-family:trebuchet ms;">"Dim ...... As ......" lines get a little tricky. </span><span style="font-family:trebuchet ms;"><span>Point Geometry </span></span><span style="font-family:trebuchet ms;"><span>for example,</span></span><span style="font-family:trebuchet ms;"><span> has 9 types including intersection point.</span></span><br /><span style="font-family:trebuchet ms;"><br /></span><span style="font-family:trebuchet ms;">HybridShapePointBetween<br /></span><span style="font-family:trebuchet ms;">HybridShapePointCenter<br /></span><span style="font-family:trebuchet ms;">HybridShapePointCoord<br /></span><span style="font-family:trebuchet ms;">HybridShapePointExplicit<br /></span><span style="font-family:trebuchet ms;">HybridShapePointOnCurve<br /></span><span style="font-family:trebuchet ms;">HybridShapePointOnPlane<br /></span><span style="font-family:trebuchet ms;">HybridShapePointOnSurface<br /></span><span style="font-family:trebuchet ms;">HybridShapePointTangent<br /></span><span style="font-family:trebuchet ms;">HybridShapeInterSection<br /><br /><span style="font-family:trebuchet ms;"><span style="font-size:85%;"><br /><br />'Module h_planeM (THIS IS ONE MODULE ONLY !!!)<br /><br />Option Explicit<br />'Author: YukiukiH<br />'Date: 10/18/2008<br />'compatibility: CATIA V5R18<br />'----------------------------------------------------------------------------------------------<br />Sub CATMain()<br /><span style="color: rgb(51, 204, 255);">'opening statement</span><br />Dim partDocument1 As PartDocument<br />Set partDocument1 = CATIA.ActiveDocument<br />Dim part1 As Part<br />Set part1 = partDocument1.Part<br /><span style="color: rgb(51, 204, 255);">'add geom set here</span><br />Dim hybridBody1 As HybridBody<br />Set hybridBody1 = part1.HybridBodies.Add()<br /> hybridBody1.Name = "D_planeM"<br />part1.Update<br /><span style="color: rgb(51, 204, 255);">'useg geom set</span><br />Dim hybridBody2 As HybridBody<br />Set hybridBody2 = part1.HybridBodies.Item("D_MidL")<br />Dim hybridBody3 As HybridBody<br />Set hybridBody3 = part1.HybridBodies.Item("D_normalM")<br /><br />Dim i As Integer<br />Dim j As Integer<br />j = 0<br />Dim k As Integer<br /><br /><span style="color: rgb(51, 204, 255);">'Loop</span><br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br />Dim lineCount As Integer<br />lineCount = hybridBody2.HybridShapes.Count<br /><br /><span style="color: rgb(51, 255, 255);">For</span> i = 1 To lineCount Step 9<br /><br /> <span style="color: rgb(51, 204, 255);">'input</span><br /> Dim line01 As HybridShapeLinePtPt<br /> Set line01 = hybridBody2.HybridShapes.Item(i)<br /> Dim lineNormal01 As HybridShapeLineNormal<br /> Set lineNormal01 = hybridBody3.HybridShapes.Item(i + j)<br /> <span style="color: rgb(51, 204, 255);">'output</span><br /> Dim plane01 As HybridShapePlane2Lines<br /> <span style="color: rgb(51, 255, 255);">Set plane01 = part1.HybridShapeFactory.AddNewPlane2Lines(line01, lineNormal01)</span><br /> hybridBody1.AppendHybridShape plane01<br /> part1.InWorkObject = plane01<br /> <br /> '---------------------------------------<br /> <span style="color: rgb(51, 255, 255);">For</span> k = 1 To 8<br /> <span style="color: rgb(51, 204, 255);">'input</span><br /> Set line01 = hybridBody2.HybridShapes.Item(i + k)<br /> Set lineNormal01 = hybridBody3.HybridShapes.Item(i + j + k)<br /> <span style="color: rgb(51, 204, 255);">'output</span><br /> <span style="color: rgb(51, 255, 255);">Set plane01 = part1.HybridShapeFactory.AddNewPlane2Lines(line01, lineNormal01)</span><br /> hybridBody1.AppendHybridShape plane01<br /> part1.InWorkObject = plane01<br /> <span style="color: rgb(51, 255, 255);">Next</span> k<br /> '---------------------------------------<br /><br /> j = j + 1<br /><span style="color: rgb(51, 255, 255);">Next</span> i<br />'----------------------------------------------------------------------------------------------<br />'----------------------------------------------------------------------------------------------<br />part1.Update 'has to be before SetRealColor<br /><br /><br /><br /><span style="color: rgb(51, 204, 255);">'color</span><br />'---------------------------------------<br />Dim colorCount<br />colorCount = hybridBody1.HybridShapes.Count<br /><span style="color: rgb(51, 255, 255);">For</span> i = 1 To colorCount<br />Call partDocument1.Selection.Add(hybridBody1.HybridShapes.Item(i))<br />Dim visProperties1 As VisPropertySet<br />Set visProperties1 = partDocument1.Selection.VisProperties<br />visProperties1.SetRealColor 0, 0, 0, 1 'blk(0, 0, 0)<br />partDocument1.Selection.Clear<br /><span style="color: rgb(51, 255, 255);">Next</span> i<br />'---------------------------------------<br />End Sub<br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-76937239800413301582008-07-13T11:53:00.001-07:002008-07-13T11:58:09.970-07:00Hanabi<a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_DACBIEbkSBY/SHpPXqqJdtI/AAAAAAAAAIM/rvV_Of5oKNc/s1600-h/hanabi.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_DACBIEbkSBY/SHpPXqqJdtI/AAAAAAAAAIM/rvV_Of5oKNc/s400/hanabi.jpg" alt="" id="BLOGGER_PHOTO_ID_5222573985896167122" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="font-family: trebuchet ms;">With a few arrangements, trees become Hanabi! (fireworks in Japanese) They are all generated from the same script, only by changing input numbers. The pointcloud on the left corner is geometrical inputs.<br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-27608389206297233282008-07-12T16:37:00.000-07:002008-07-13T16:27:16.284-07:00Evolution<a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_DACBIEbkSBY/SHpLpgsAfVI/AAAAAAAAAIE/oDgfxu2zeGg/s1600-h/evolution.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_DACBIEbkSBY/SHpLpgsAfVI/AAAAAAAAAIE/oDgfxu2zeGg/s320/evolution.jpg" alt="" id="BLOGGER_PHOTO_ID_5222569894410747218" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;"><br />Playing around with the find closest script I posted previously, I have been growing bunch of trees. If I look only the final result, it looks sort of intimidating. But I start with the simple code like find closest, and kept adding more functions and intelligence. I also work this way when I have to figure out complicated powercopy.</span><br /><br /><br /><a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_DACBIEbkSBY/SHpLjKSAOaI/AAAAAAAAAH8/QMr6kBF4ASc/s1600-h/type0102.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp0.blogger.com/_DACBIEbkSBY/SHpLjKSAOaI/AAAAAAAAAH8/QMr6kBF4ASc/s320/type0102.jpg" alt="" id="BLOGGER_PHOTO_ID_5222569785316882850" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;">If you look close, tangency of branches appear more smoothly in type02. This regards the order that code generates branches. It makes sense that more points the code takes into consideration in the beginning (like in type02), the more naturally tangency can grow.<br /><br />I have to learn how to call function for some part of the script, otherwise, scripts I write are getting too long to post... If somebody is interested, please let me know.<br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-13253241835574127132008-07-04T07:31:00.000-07:002008-12-02T23:29:06.960-08:00Branching<a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_DACBIEbkSBY/SG5U4Z137fI/AAAAAAAAAHk/aMsJ74BOvC4/s1600-h/branching.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp0.blogger.com/_DACBIEbkSBY/SG5U4Z137fI/AAAAAAAAAHk/aMsJ74BOvC4/s320/branching.jpg" alt="" id="BLOGGER_PHOTO_ID_5219202346155240946" border="0" /></a><br /><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br /><br /><br /><a href="http://ssssociety.blogspot.com/2008/09/makebranch-revision.html">** Updated Branching Script</a><br /><br /><br />Very simple operation to find closest point out of point cloud. </span><span style="font-family:trebuchet ms;">I have some more work to do on this script, so</span><span style="font-family:trebuchet ms;"> I wanted to post it up before I make it too complicated.<br /><br /></span><span style="font-family:trebuchet ms;">Each Loop finds first closest, second closest, third closest, so on and so forth. I thought it would be cool to set a variable that defines how many closest point each target has to find, but I couldn't figure out. Let's just start with recycling the same Loop over and over again.<br /><br /></span><span style="font-family:trebuchet ms;">It looks like I can make this script much shorter if<br /><span style="color: rgb(51, 204, 255);">Call Rhino.PointArrayClosestPoint (arrPoints( ), arrPoint)</span><br />works... This sample appears in monkey, yet somehow Rhino Script Method is not available.<br /></span><br /><br /><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >Option Explicit<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'Author: YukiukiH<br />'Date: 06/04/2008<br />'compatibility: Rhino4<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'memo: </span><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="color: rgb(51, 204, 255);">boundary is variable in plan</span><br /><br />Branching()<br />Sub Branching()<br />Dim a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z<br /><br />Dim arrstrStPt, arrStPt()<br />Dim arrstrEdPt(), arrEdPt()<br />Dim arrstrALLEdPt, arrALLEdPt()<br /><br /><span style="color: rgb(51, 204, 255);">'user selection</span><br />arrstrStPt = Rhino.GetObjects ("select root points", 1)<br />arrstrALLEdPt = Rhino.GetObjects ("select reference points", 1)<br />Rhino.Print <span style="color: rgb(102, 255, 255);">"MINIMIZE RHINO WHINDOW TO SAVE TIME !!!"</span><br /><br />For i = 0 To UBound(arrstrStPt)<br />ReDim Preserve arrStPt(i)<br />arrStPt(i) = Rhino.PointCoordinates (arrstrStPt(i))<br />Next<br /><br />For i = 0 To UBound(arrstrALLEdPt)<br />ReDim Preserve arrALLEdPt(i)<br />arrALLEdPt(i) = Rhino.PointCoordinates (arrstrALLEdPt(i))<br />Next</span><span style=";font-family:trebuchet ms;font-size:85%;" ></span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /><span style="color: rgb(51, 204, 255);">'set boundary </span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ></span><br /><span style=";font-family:trebuchet ms;font-size:85%;" >Dim dblmaxX, dblminX, dblmaxY, dblminY<br /><br /><span style="color: rgb(51, 204, 255);">'Ultimate Loop</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="color: rgb(102, 255, 255);">b = 100</span><span style="color: rgb(102, 255, 255); font-weight: bold;"><br /></span></span><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="font-weight: bold;">For</span> j = 0 To UBound(arrStPt)<br /><br />dblmaxX = arrStPt(j)(0) <span style="color: rgb(51, 255, 255);"><span style="color: rgb(102, 255, 255);">+b</span> </span><br />dblminX = arrStPt(j)(0) <span style="color: rgb(102, 255, 255);">-b </span><br />dblmaxY = arrStPt(j)(1) <span style="color: rgb(102, 255, 255);">+b </span><br />dblminY = arrStPt(j)(1) <span style="color: rgb(102, 255, 255);">-b </span><br /><br />n = 0<br />For m = 0 To UBound(arrstrALLEdPt)<br />If dblmaxX > arrALLEdPt(m)(0) And arrALLEdPt(m)(0) > dblminX And dblmaxY > arrALLEdPt(m)(1) And arrALLEdPt(m)(1) > dblminY Then<br />ReDim Preserve arrstrEdPt(n)<br />arrstrEdPt(n) = Rhino.CopyObject (arrstrALLEdPt(m))<br />ReDim Preserve arrEdPt(n)<br />arrEdPt(n) = Rhino.PointCoordinates (arrstrEdPt(n))<br />n = n+1<br />End If<br /><br />Next<br />Call Rhino.DeleteObjects (arrstrEdPt)<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /><span style="color: rgb(51, 204, 255);">'comparison</span><br />Dim strLine01, dblDist01<br />Dim strLine02, dblDist02<br />Dim strPrevShortest, dblPrevShortest<br />Dim strCurrShortest, dblCurrShortest<br /><br /><span style="color: rgb(51, 204, 255);">'find shortest</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" >i = 0 'make one to begin comparison with<br />strLine01 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist01 = Rhino.CurveLength (strLine01)<br />strPrevShortest = strLine01<br />dblPrevShortest = dblDist01<br /><br /><span style="font-weight: bold;font-family:trebuchet ms;" >For</span><span style="font-family:trebuchet ms;"> i = 0 To UBound(arrEdPt)</span><br /><span style="font-family:trebuchet ms;">strLine02 = Rhino.AddLine (arrStPt(j), arrEdPt(i))</span><br /><span style="font-family:trebuchet ms;">dblDist02 = Rhino.CurveLength (strLine02)</span><br /><br /><span style="font-family:trebuchet ms;">If dblDist02 <= dblPrevShortest Then</span><br /><span style="font-family:trebuchet ms;">strCurrShortest = strLine02 </span><br /><span style="font-family:trebuchet ms;">dblCurrShortest = dblDist02 </span><br /><span style="font-family:trebuchet ms;">Rhino.DeleteObject strPrevShortest </span><br /><span style="font-family:trebuchet ms;">Else </span><br /><span style="font-family:trebuchet ms;">strCurrShortest = strPrevShortest </span><br /><span style="font-family:trebuchet ms;">dblCurrShortest = dblPrevShortest </span><br /><span style="font-family:trebuchet ms;">Rhino.DeleteObject strLine02 </span><br /><span style="font-family:trebuchet ms;">End If </span><br /><br /><span style="font-family:trebuchet ms;">'prepare for next round </span><br /><span style="font-family:trebuchet ms;">strPrevShortest = strCurrShortest </span><br /><span style="font-family:trebuchet ms;">dblPrevShortest = dblCurrShortest </span><br /><span style="font-family:trebuchet ms;">'Rhino.Sleep 10 </span><br /><span style="font-weight: bold;font-family:trebuchet ms;" >Next</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><span style="color: rgb(51, 204, 255);">'find second</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br />Rhino.AddLayer <span style="color: rgb(102, 255, 255);">"1st shortest"</span>, RGB(0,255,255) 'cyan<br />Rhino.ObjectLayer strCurrShortest, <span style="color: rgb(102, 255, 255);">"1st shortest"</span><br />Dim <span style="color: rgb(102, 255, 255);">dbl1stShortest</span>, <span style="color: rgb(102, 255, 255);">str1stShortest</span><br /><span style="color: rgb(102, 255, 255);">dbl1stShortest</span> = Rhino.CurveLength (strPrevShortest)<br /><span style="color: rgb(51, 255, 255);"><span style="color: rgb(102, 255, 255);">str1stShortest</span> </span>= strPrevShortest<br /><br />i = 0 'make one to begin comparison with<br />strLine01 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist01 = Rhino.CurveLength (strLine01)<br /><br />If dblDist01 <= <span style="color: rgb(102, 255, 255);">dbl1stShortest</span> Then<br />dblDist01 = dblDist01 * 10<br />End If<br /><br />strPrevShortest = strLine01<br />dblPrevShortest = dblDist01<br /><br /><span style="font-weight: bold;">For</span> i = 0 To UBound(arrEdPt)<br />strLine02 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist02 = Rhino.CurveLength (strLine02)<br /><br />If dblDist02 <= dblPrevShortest And dblDist02 > <span style="color: rgb(102, 255, 255);">dbl1stShortest</span> Then<br />strCurrShortest = strLine02<br />dblCurrShortest = dblDist02<br />Rhino.DeleteObject strPrevShortest<br />Else<br />strCurrShortest = strPrevShortest<br />dblCurrShortest = dblPrevShortest<br />Rhino.DeleteObject strLine02 <br />End If<br /><br />'prepare for next round<br />strPrevShortest = strCurrShortest<br />dblPrevShortest = dblCurrShortest<br />'Rhino.Sleep 10<br /><span style="font-weight: bold;">Next</span></span><span style=";font-family:trebuchet ms;font-size:85%;" ><br />'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /><span style="color: rgb(51, 204, 255);">'find third</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" >Rhino.AddLayer <span style="color: rgb(102, 255, 255);">"2nd shortest"</span>, RGB(0,0,191) 'dark blue<br />Rhino.ObjectLayer strCurrShortest, <span style="color: rgb(102, 255, 255);">"2nd shortest"</span><br />Dim <span style="color: rgb(102, 255, 255);">dbl2ndShortest</span>, <span style="color: rgb(102, 255, 255);">str2ndShortest</span><br /><span style="color: rgb(102, 255, 255);">dbl2ndShortest</span> = Rhino.CurveLength (strPrevShortest)<br /><span style="color: rgb(102, 255, 255);">str2ndShortest</span> = strPrevShortest<br /><br />i = 0 'make one to begin comparison with<br />strLine01 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist01 = Rhino.CurveLength (strLine01)<br /><br />If dblDist01 <= <span style="color: rgb(102, 255, 255);">dbl2ndShortest</span> Then<br />dblDist01 = dblDist01 * 10<br />End If<br />strPrevShortest = strLine01<br />dblPrevShortest = dblDist01<br /><br /><span style="font-weight: bold;">For </span>i = 0 To UBound(arrEdPt)<br />strLine02 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist02 = Rhino.CurveLength (strLine02)<br /><br />If dblDist02 <= dblPrevShortest And dblDist02 > <span style="color: rgb(102, 255, 255);">dbl2ndShortest</span><span style="color: rgb(102, 255, 255);"> </span>Then<br />strCurrShortest = strLine02<br />dblCurrShortest = dblDist02<br />Rhino.DeleteObject strPrevShortest<br />Else<br />strCurrShortest = strPrevShortest<br />dblCurrShortest = dblPrevShortest<br />Rhino.DeleteObject strLine02 <br />End If<br /><br />'prepare for next round<br />strPrevShortest = strCurrShortest<br />dblPrevShortest = dblCurrShortest<br />'Rhino.Sleep 10<br /><span style="font-weight: bold;">Next</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br />'find fourth<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" >Rhino.AddLayer <span style="color: rgb(102, 255, 255);">"3rd shortest"</span>, RGB(127,255,191) 'Aquamarine<br />Rhino.ObjectLayer strCurrShortest, <span style="color: rgb(102, 255, 255);">"3rd shortest"</span><br />Dim <span style="color: rgb(102, 255, 255);">dbl3rdShortest</span>, <span style="color: rgb(102, 255, 255);">str3rdShortest</span><br /><span style="color: rgb(102, 255, 255);">dbl3rdShortest</span> = Rhino.CurveLength (strPrevShortest)<br /><span style="color: rgb(102, 255, 255);">str3rdShortest</span> = strPrevShortest<br /><br />i = 0 'make one to begin comparison with<br />strLine01 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist01 = Rhino.CurveLength (strLine01)<br /><br />If dblDist01 <=<span style="color: rgb(102, 255, 255);"> dbl3rdShortest</span> Then<br />dblDist01 = dblDist01 * 10<br />End If<br />strPrevShortest = strLine01<br />dblPrevShortest = dblDist01<br /><br /><span style="font-weight: bold;">For</span> i = 0 To UBound(arrEdPt)<br />strLine02 = Rhino.AddLine (arrStPt(j), arrEdPt(i))<br />dblDist02 = Rhino.CurveLength (strLine02)<br /><br />If dblDist02 <= dblPrevShortest And dblDist02 > <span style="color: rgb(102, 255, 255);">dbl3rdShortest</span> Then<br />strCurrShortest = strLine02<br />dblCurrShortest = dblDist02<br />Rhino.DeleteObject strPrevShortest<br />Else<br />strCurrShortest = strPrevShortest<br />dblCurrShortest = dblPrevShortest<br />Rhino.DeleteObject strLine02<br />End If<br /><br />'prepare for next round<br />strPrevShortest = strCurrShortest<br />dblPrevShortest = dblCurrShortest<br />'Rhino.Sleep 10<br /><span style="font-weight: bold;">Next</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /><br /><br /><br /><br /><br /><span style="color: rgb(51, 204, 255);">'paste above here </span></span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" >Rhino.AddLayer <span style="color: rgb(102, 255, 255);">"final shortest"</span>, RGB(255,255,255) 'white<br />Rhino.ObjectLayer strCurrShortest, <span style="color: rgb(102, 255, 255);">"final shortest"</span><br />Dim <span style="color: rgb(102, 255, 255);">dblFinalShortest</span>, <span style="color: rgb(102, 255, 255);">strFinalShortest</span><br /><span style="color: rgb(102, 255, 255);">dblFinalShortest</span> = Rhino.CurveLength (strPrevShortest)<br /><span style="color: rgb(102, 255, 255);">strFinalShortest </span>= strPrevShortest</span><span style=";font-family:trebuchet ms;font-size:85%;" ></span><br /><span style=";font-family:trebuchet ms;font-size:85%;" ></span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="font-weight: bold;">Next </span></span><span style=";font-family:trebuchet ms;font-size:85%;" ><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ></span><span style=";font-family:trebuchet ms;font-size:85%;" ></span><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><span style="font-weight: bold;"></span><br />Call Rhino.Print ("script complete")<br />End Sub<br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-63796638630921388332008-06-28T12:31:00.001-07:002008-07-12T09:28:46.560-07:00Finite Element Analysis<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_DACBIEbkSBY/SHja3s9KrkI/AAAAAAAAAHs/q8_4RrbOOVc/s1600-h/bridge02.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_DACBIEbkSBY/SHja3s9KrkI/AAAAAAAAAHs/q8_4RrbOOVc/s320/bridge02.jpg" alt="" id="BLOGGER_PHOTO_ID_5222164418431462978" border="0" /></a><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br />Creating geometry for Finite Element Analysis (FEA). FEA is a computer simulation </span><span style="font-family:trebuchet ms;">technique used in engineering analysis (straight from Wiki...) It requires all the line geometries to be meeting at points. If you are Osnap-ing manually, there is high chance that you miss a couple. So, here it is. Out of spline and two offset splines, this script creates basic structure for a bridge.<br /><br /></span><span style="font-family:trebuchet ms;">User has to provide with </span><span style="font-family:trebuchet ms;">manually-built </span><span style="font-family:trebuchet ms;">normals at each division point. Length doesn't matter. It is to show direction only, and will be deleted by the end of the script.<br /><br /><span style="color: rgb(255, 153, 0);">Challenge:</span><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" >_Confusion between stringPt and arrPt</span><span style=";font-family:trebuchet ms;font-size:100%;" ><br /></span><span style="font-family:trebuchet ms;"><span style="font-size:100%;">_Playing with Layer method<br />_In Loop, lines require to refer a point from previous round</span><br /><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br />Option Explicit<br /></span><span style="font-size:85%;"><span style="font-family:trebuchet ms;">'Author: YukiukiH</span><br /><span style="font-family:trebuchet ms;">'</span><span style="font-family:trebuchet ms;">Date: 06/28/2008</span><br /><span style="font-family:trebuchet ms;">'compatibility: Rhino4</span><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'memo: watch arrPt and strPt<br /><br />'before run...<br />'1. given spline.<br />'2. divide spline.<br />'3. draw normal at each points. (use perpendicular to curve/ from first point)<br /><br /><br />bridgeSt<br />Sub bridgeSt<br /><br /><span style="color: rgb(255, 153, 0);">'first things first...</span><br />Rhino.AddLayer "splineCenter", RGB(255,0,0) 'black<br />Rhino.AddLayer "centerPt", RGB(0,0,0) 'black<br />Rhino.AddLayer "normalAxis", RGB(0,0,0) 'black<br />Rhino.AddLayer "normal01", RGB(255,161,0) 'gold<br />Rhino.AddLayer "normal02", RGB(255,127,0) 'orange<br />Rhino.AddLayer "side01", RGB(0,0,0) 'black<br />Rhino.AddLayer "side02", RGB(0,0,0) 'black<br />Rhino.AddLayer "Pt", RGB(0,0,0) 'black<br /><br />Rhino.AddLayer "Line011", RGB(63,191,191) 'turquoise<br />Rhino.AddLayer "Line022", RGB(63,191,191) 'turquoise<br />Rhino.AddLayer "Line033", RGB(0,0,0) 'black<br />Rhino.AddLayer "Line044", RGB(0,0,0) 'black<br />Rhino.AddLayer "Line055", RGB(255,0,0) 'red<br /><br /><br /><br /><span style="color: rgb(255, 153, 0);">'organizing object layers</span><br />Dim strSpline, arrstrCenPt, arrstrNormalAxis<br />Dim arrPt, arrPts, strCenPt, dblLength<br /><br />strSpline = Rhino.GetObject ("select a spline curve", 4)<br />Rhino.ObjectLayer strSpline , "splineCenter"<br />Rhino.LayerVisible "splineCenter", False<br /><br />arrstrCenPt = Rhino.GetObjects ("select center points", 1)<br />Rhino.ObjectLayer arrstrCenPt , "centerPt"<br />Rhino.CurrentLayer ("CenterPt")<br />Rhino.DeleteObjects arrstrCenPt<br /><br />'by length segment<br />dblLength = 1500<br />arrPts = Rhino.DivideCurveLength(strSpline, dblLength)<br /><br />'by segments<br />'intSegments = 130<br />'arrPoints = Rhino.DivideCurve(strSpline, intSegments)<br /><br />For Each arrPt In arrPts<br />strCenPt = Rhino.AddPoint (arrPt)<br />Next<br /><br />arrstrNormalAxis = Rhino.GetObjects ("select normal lines IN ORDER", 4)<br />Rhino.ObjectLayer arrstrNormalAxis , "normalAxis"<br /><br /><br /><span style="color: rgb(255, 153, 0);">'at each point...</span><br /><br />Dim i, arrNormalAxisStPt, arrNormalAxisEdPt<br />Dim strLine01, strLine02, arrSt(2), arrEd(2), arrReference(1), arrTarget(1)<br /><br />arrSt(0) = 0<br />arrSt(1) = 0<br />arrSt(2) = 0<br />arrEd(0) = 2000 'bridge width<br />arrEd(1) = 0<br />arrEd(2) = 0<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">For i = 0 To UBound</span> (arrstrNormalAxis)<br /><br /><span style="color: rgb(255, 153, 0);">'create vector out of string normal, and orient lines</span><br />arrNormalAxisStPt = Rhino.CurveStartPoint (arrstrNormalAxis(i))<br />arrNormalAxisEdPt = Rhino.CurveEndPoint (arrstrNormalAxis(i))<br />Rhino.LayerVisible "normalAxis", False<br /><br />arrReference(0) = arrSt<br />arrReference(1) = arrEd<br />arrTarget(0) = arrNormalAxisStPt<br />arrTarget(1) = arrNormalAxisEdPt<br /><br />Rhino.CurrentLayer ("normal01")<br />strLine01 = Rhino.AddLine (arrSt, arrEd)<br />Rhino.OrientObject strLine01, arrReference, arrTarget<br /><br />Rhino.CurrentLayer ("normal02")<br />strLine02 = Rhino.AddLine (arrSt, arrEd)<br />Rhino.OrientObject strLine02, arrReference, arrTarget<br />Rhino.RotateObject strLine02, arrNormalAxisStPt, 180<br /><br /><br /><br /><span style="color: rgb(255, 153, 0);">'prepare vector for 3d rotation</span><br />Dim arrLine01EdPt, arrLine02EdPt<br />Dim strLine01axis, strLine02axis<br />Dim arrLine01StPt, arrLine02StPt, arrAxis01, arrAxis02<br />Dim strLine01vrt, strLine02vrt<br /><br />arrLine01EdPt = Rhino.CurveEndPoint (strLine01)<br />arrLine02EdPt = Rhino.CurveEndPoint (strLine02)<br /><br />strLine01axis = Rhino.RotateObject (strLine01, arrLine01EdPt, 90,, True)<br />strLine02axis = Rhino.RotateObject (strLine02, arrLine02EdPt, 90,, True)<br /><br />arrLine01StPt = Rhino.CurveStartPoint (strLine01axis)<br />arrLine02StPt = Rhino.CurveStartPoint (strLine02axis)<br /><br />arrAxis01= Rhino.VectorCreate (arrLine01EdPt, arrLine01StPt)<br />arrAxis02= Rhino.VectorCreate (arrLine02EdPt, arrLine02StPt)<br /><br />strLine01vrt = Rhino.CopyObject(strLine01)<br />Rhino.ObjectLayer strLine01vrt, "side01"<br />Rhino.RotateObject strLine01vrt, arrLine01EdPt, 100, arrAxis01<br /><br />strLine02vrt = Rhino.CopyObject(strLine02)<br />Rhino.ObjectLayer strLine02vrt, "side02"<br />Rhino.RotateObject strLine02vrt, arrLine02EdPt, 100, arrAxis02<br /><br />Rhino.DeleteObject (strLine01axis)<br />Rhino.DeleteObject (strLine02axis)<br /><br /><br /><br /><span style="color: rgb(255, 153, 0);">'add string points</span><br />Dim arrStPtLine01vrt, arrStPtLine02vrt, arrEdPtLine01vrt, arrEdPtLine02vrt<br />Dim strStPtLine01vrt, strStPtLine02vrt, strEdPtLine01vrt, strEdPtLine02vrt<br /><br />Rhino.CurrentLayer ("Pt")<br /><br />arrStPtLine01vrt = Rhino.CurveStartPoint (strLine01vrt)<br />arrStPtLine02vrt = Rhino.CurveStartPoint (strLine02vrt)<br />strStPtLine01vrt = Rhino.AddPoint (arrStPtLine01vrt)<br />strStPtLine02vrt = Rhino.AddPoint (arrStPtLine02vrt)<br /><br />arrEdPtLine01vrt = Rhino.CurveEndPoint (strLine01vrt)<br />arrEdPtLine02vrt = Rhino.CurveEndPoint (strLine02vrt)<br />strEdPtLine01vrt = Rhino.AddPoint (arrEdPtLine01vrt)<br />strEdPtLine02vrt = Rhino.AddPoint (arrEdPtLine02vrt)<br /><br /><br /><br /><span style="color: rgb(255, 153, 0);">'create lines between current(B) and previous(A)</span><br />Dim strLine011, arrLine011PtA, arrLine011PtB, arrpt011PtAtemp<br />Dim strLine022, arrLine022PtA, arrLine022PtB, arrpt022PtAtemp<br />Dim strLine033, arrLine033PtA, arrLine033PtB, arrpt033PtAtemp<br />Dim strLine044, arrLine044PtA, arrLine044PtB, arrpt044PtAtemp<br />Dim strLine055, arrLine055PtA, arrLine055PtB, arrpt055PtAtemp<br />Dim strEdPtVrt03, strEdPtVrt04<br /><br /><br /><span style="color: rgb(255, 153, 0);">'prepare current(B) and previous(A)points</span><br />If i = 0 Then<br /><br />'BTM line (Line011, 022)<br />arrLine011PtA = arrLine01EdPt<br />arrLine022PtA = arrLine02EdPt<br /><br />'TP line (Line 033, 044)<br />arrLine033PtA = Rhino.CurveStartPoint (strLine01vrt)<br />arrLine044PtA = Rhino.CurveStartPoint (strLine02vrt)<br /><br />'MD line (Line 055)<br />arrLine055PtA = arrPts(i)<br /><br />Else<br /><br />'BTM line (Line011, 022)<br />arrpt011PtAtemp = arrLine01EdPt<br />arrpt022PtAtemp = arrLine02EdPt<br />arrLine011PtB = arrpt011PtAtemp<br />arrLine022PtB = arrpt022PtAtemp<br /><br />'TP line (Line 033, 044)<br />arrpt033PtAtemp = Rhino.CurveStartPoint (strLine01vrt)<br />arrpt044PtAtemp = Rhino.CurveStartPoint (strLine02vrt)<br />arrLine033PtB = arrpt033PtAtemp<br />arrLine044PtB = arrpt044PtAtemp<br /><br />'MD line (Line 055)<br />arrpt055PtAtemp = arrPts(i)<br />arrLine055PtB = arrpt055PtAtemp<br /><br /><br /><span style="color: rgb(255, 153, 0);">'add line (Line 011, 022, 033, 044, 055)</span><br />Rhino.CurrentLayer ("Line011")<br />strLine011 = Rhino.AddLine (arrLine011PtA, arrLine011PtB)<br /><br />Rhino.CurrentLayer ("Line022")<br />strLine022 = Rhino.AddLine (arrLine022PtA, arrLine022PtB)<br /><br />Rhino.CurrentLayer ("Line033")<br />strLine033 = Rhino.AddLine (arrLine033PtA, arrLine033PtB)<br /><br />Rhino.CurrentLayer ("Line044")<br />strLine044 = Rhino.AddLine (arrLine044PtA, arrLine044PtB)<br /><br />Rhino.CurrentLayer ("Line055")<br />strLine055 = Rhino.AddLine (arrLine055PtA, arrLine055PtB)<br /><br /><br /><span style="color: rgb(255, 153, 0);"> ' prepare for next round </span><br />'BTM line (Line011, 022)<br />arrLine011PtA = arrLine011PtB<br />arrLine022PtA = arrLine022PtB<br /><br />'TP line (Line033, 044)<br />arrLine033PtA = arrLine033PtB<br />arrLine044PtA = arrLine044PtB<br /><br />'MD line (Line055)<br />arrLine055PtA = arrLine055PtB<br /><br />End If<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">Next</span><br />End Sub<br /><br /></span><span style="font-family:trebuchet ms;"><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-10719643624668526872008-06-21T11:52:00.000-07:002008-07-12T10:43:50.323-07:00Normal to Curve<span style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_DACBIEbkSBY/SHjqF9ErwfI/AAAAAAAAAH0/ylw3Mzvrhj0/s1600-h/bridge00.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp0.blogger.com/_DACBIEbkSBY/SHjqF9ErwfI/AAAAAAAAAH0/ylw3Mzvrhj0/s320/bridge00.jpg" alt="" id="BLOGGER_PHOTO_ID_5222181155950543346" border="0" /></a><br /><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" ><br /><br /><br /><br /><br /><br /><br /><br /><br />Having hard time with </span><span style=";font-family:trebuchet ms;font-size:100%;" ><span style="color: rgb(255, 0, 0);">drawing normal (of the main spline) at each division point</span> I ended up intersecting circle and offset splines. </span><span style=";font-family:trebuchet ms;font-size:100%;" >So when I first offset the main spline, I had to set offset tolerance high, at least more than default otherwise intersection fails.<br /><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" ><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" ><br />Option Explicit<br /></span><span style="font-size:85%;"><span style="font-family:trebuchet ms;">'Author: YukiukiH</span><br /><span style="font-family:trebuchet ms;">'</span><span style="font-family:trebuchet ms;">Date: 06/21/2008</span><br /><span style="font-family:trebuchet ms;">'compatibility: Rhino4</span><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" ><span style="font-size:85%;">'memo: watch arrPt and strPt<br /><br />bridgeSt<br />Sub bridgeSt<br /><br /></span><span style="color: rgb(255, 153, 0);font-size:85%;" >'first things first...</span><span style="font-size:85%;"><br />Rhino.AddLayer "centerPt", RGB(0,0,0) 'black<br />Rhino.AddLayer "circle", RGB(105,105,105) 'darl gray<br />Rhino.AddLayer "normal01", RGB(255,161,0) 'gold<br />Rhino.AddLayer "normal02", RGB(255,127,0) 'orange<br />Rhino.AddLayer "Pt", RGB(0,0,0) 'black<br />Rhino.CurrentLayer ("centerPt")<br /><br /></span><span style="color: rgb(255, 153, 0);font-size:85%;" >'divide bridge spline into segments (by length or segments)</span><span style="font-size:85%;"><br />Dim strSpline, dblLength, intSegments<br />Dim strOffset01, strOffset02<br />Dim arrPts, arrPt, strCenPt<br /><br />strSpline = Rhino.GetObject("Select a curve")<br />strOffset01 = Rhino.GetObject("Select the first offset curve")<br />strOffset02 = Rhino.GetObject("Select the second offset curve")<br />Call Rhino.LayerVisible ("splineCenter", False)<br />Call Rhino.LayerVisible ("splineOffset", False)<br /><br />If Rhino.IsCurve(strSpline) Then<br />'by length segment<br />dblLength = 1500<br />arrPts = Rhino.DivideCurveLength(strSpline, dblLength)<br />'by segments<br />'intSegments = 130<br />'arrPoints = Rhino.DivideCurve(strSpline, intSegments)<br />For Each arrPt In arrPts<br />strCenPt = Rhino.AddPoint (arrPt)<br />Next<br />End If<br /><br /><br /><span style="color: rgb(255, 153, 0);">'Ultimate Loop</span><br /></span></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:100%;" ><span style="font-size:85%;">Dim i, k<br /></span><span style="font-weight: bold;font-size:85%;" >For</span><span style="font-size:85%;"> i = 0 To UBound(arrPts)<br /><br /></span><span style="color: rgb(255, 153, 0);font-size:85%;" >'intersection (circle and offset spline) finds normal </span><span style="font-size:85%;"><br />Dim strCircle, arrPlane, arrInterPt01, arrInterPt02<br /><br />arrPlane = Rhino.WorldXYPlane<br />strCircle = Rhino.AddCircle (arrPlane, 2000)<br />Call Rhino.ObjectLayer (strCircle, "circle")<br />Rhino.MoveObject strCircle, Array(0,0,0), arrPts(i)<br /><br />Rhino.CurrentLayer ("Pt")<br />arrInterPt01 = Rhino.CurveCurveIntersection(strOffset01, strCircle)<br /><br />If Not IsArray(arrInterPt01) Then<br />Rhino.Print "Selected curves do not intersect"<br />Exit Sub<br />End If<br /><br />If arrInterPt01(k,0) = 1 Then<br />Rhino.Print "Intersection point on first curve: " & Rhino.Pt2Str(arrInterPt01(k,1))<br />Rhino.AddPoint arrInterPt01(k,1)<br />Else<br />Rhino.Print "Overlap"<br />Exit Sub<br />End If<br /><br />arrInterPt02 = Rhino.CurveCurveIntersection(strOffset02, strCircle)<br />If Not IsArray(arrInterPt02) Then<br />Rhino.Print "Selected curves do not intersect"<br />Exit Sub<br />End If<br /><br />If arrInterPt02(k,0) = 1 Then<br />Rhino.Print "Intersection point on first curve: " & Rhino.Pt2Str(arrInterPt02(k,1))<br />Rhino.AddPoint arrInterPt02(k,1)<br />Else<br />Rhino.Print "Overlap"<br />Exit Sub<br />End If<br /><br /></span><span style="color: rgb(255, 153, 0);font-size:85%;" >'add normal line </span><span style="font-size:85%;"><br />Dim strLine01, strLine02, strLine01axis, strLine02axis<br />Dim arrStPtLine01, arrStPtLine02, arrAxis01, arrAxis02<br />Dim strLine01vrt, strLine02vrt<br /><br />Rhino.CurrentLayer ("normal01")<br />strLine01 = Rhino.AddLine (arrPts(i), arrInterPt01(k,1))<br />Rhino.CurrentLayer ("normal02")<br />strLine02 = Rhino.AddLine (arrPts(i), arrInterPt02(k,1))<br /><br /></span><span style="font-weight: bold;font-size:85%;" >Next</span><span style="font-size:85%;"><br /></span></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------<br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >'----------------------------------------------------------------</span><span style=";font-family:trebuchet ms;font-size:85%;" >------------------------------</span><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br /></span><span style=";font-family:trebuchet ms;font-size:100%;" ><span style="font-size:85%;">Call Rhino.LayerVisible ("splineCenter", True)<br />Call Rhino.LayerVisible ("splineOffset", True)<br />Call Rhino.print ("script complete")<br />End Sub<br /></span><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-66622463798829711712008-03-16T20:00:00.001-07:002008-06-21T12:06:26.059-07:00Ball Tracking<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_DACBIEbkSBY/R93fxjESKVI/AAAAAAAAAGQ/AHBDLeboASk/s1600-h/renderimage6.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_DACBIEbkSBY/R93fxjESKVI/AAAAAAAAAGQ/AHBDLeboASk/s400/renderimage6.jpg" alt="" id="BLOGGER_PHOTO_ID_5178541188865730898" border="0" /></a><br /><br /><br /><span style="font-family:trebuchet ms;"><br />Recently finished Nick Pisca's MEL scripting workshop and found MEL is a lot of fun. Seems much smarter than Rhino in a lot of ways. Things like declarations and arrays are much easier although the case sensitive stuff gets me all the time. We didn't cover procedures in the workshop but got to hit a lot of ground including scripting material assignment and rendering.</span><br /><br /><span style="font-family:trebuchet ms;">Here's a simple tracking script where planes duplicate and deform while following an animated object. I'll post the video sometime in the future.</span><br /><br /><br /><span style=";font-family:trebuchet ms;font-size:85%;" ><br />//Tracking script<br />//<br />//Written by: Sky Milner<br />//Date: 3-03-08<br />//Contributor: Nick Pisca<br />//<br />//This script duplicates selected objects based on the<br />//location of a target.<br />//<br />//Setup:<br />//First make an object and call it "Target", Animate target as you like, make 6 nurbsPlanes<br />//<br />//<br />//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br /><br /><br /><br />string $Selection[] = {"nurbsPlane1", "nurbsPlane2", "nurbsPlane2", "nurbsPlane3", "nurbsPlane3","nurbsPlane4","nurbsPlane4","nurbsPlane5","nurbsPlane5","nurbsPlane6", "nurbsPlane6","nurbsPlane1"};<br />int $SelSize = size($Selection);<br />int $SquareCounter = 0;<br /><br />for ($i = 0; $i < currentnumber =" 0;" selectioncounter =" 0;" firstobject =" $Selection[$CurrentNumber];" secondobject =" $Selection[$CurrentNumber+1];" vecfirst =" <<$XYZfirst[0],">> ;<br /><br /> float $XYZsecond[] = `pointPosition ($SecondObject + ".cv [0] [0]")` ;<br /> vector $VecSecond = <<$XYZsecond[0], $XYZsecond[1], $XYZsecond[2]>> ;<br /><br /> float $XYZtarget[] = `pointPosition ("Target.cv [0] [0]")`;<br /> vector $VecTarget = <<$XYZtarget[0], $XYZtarget[1], $XYZtarget[2]>>;<br /><br /><br /> $Between = $VecFirst - $VecSecond;<br /><br /> //Duplicate and move into position<br /><br /> duplicate -rr -n ("series"+$i+"square"+$SquareCounter) $Selection[($CurrentNumber)];<br /><br /> string $Duplicate = ("series"+$i+"square"+$SquareCounter);<br /><br /><br /> //setAttr ($Duplicate+ ".translate") ($XYZfirst[0] + $Between.x/(-2)) ($XYZfirst[1] + $Between.y / (-2) ) ($XYZfirst[2] + $Between.z / (-2));<br /><br />xform -r -t ($Between.x/(-2)) ($Between.y / (-2)) ($Between.z / (-2)) $Duplicate;<br /><br /><br /> float $XYZduplicate[] = `pointPosition ($Duplicate + ".cv [0] [0]")`;<br /> vector $Vecduplicate = <<$XYZduplicate[0], $XYZduplicate[1], $XYZduplicate[2]>>;<br /><br /> $Between2 = $VecTarget - $Vecduplicate;<br /><br /> //setAttr ($Duplicate+ ".translate") ($XYZduplicate[0] + $Between2.x/4) ($XYZduplicate[1] + $Between2.y/2) ($XYZduplicate[2] + $Between2.z/4);<br /><br />xform -r -t ($Between2.x/4) ($Between2.y/2) ($Between2.z/4) $Duplicate;<br /><br /><br /> //Scale Duplicate<br /><br /> float $scalefactor = ((mag($Between2)*.01)+.75);<br /><br /> //setAttr ($Duplicate+ ".scaleX") $scalefactor;<br /> //setAttr ($Duplicate+ ".scaleY") $scalefactor;<br /> //setAttr ($Duplicate+ ".scaleZ") $scalefactor;<br /><br /><br /> //Manipulate cv[0]<br /><br /> float $PointX = `getAttr ($Duplicate + ".cv[0].xValue")`;<br /> float $PointY = `getAttr ($Duplicate + ".cv[0].yValue")`;<br /> float $PointZ = `getAttr ($Duplicate + ".cv[0].zValue")`;<br /><br /> vector $VecPoint = <<$PointX, $PointY, $PointZ>>;<br /><br /> $Between3 = $VecTarget - $VecPoint;<br /><br /> setAttr ($Duplicate+ ".cv[0].xValue") ($PointX + $Between3.x/(10));<br /> setAttr ($Duplicate+ ".cv[0].yValue") ($PointY + $Between3.y/(10));<br /> setAttr ($Duplicate+ ".cv[0].zValue") ($PointZ + $Between3.z/(10));<br /><br /> //setAttr ($Duplicate + ".objectColor") $SquareCounter;<br /><br /></span><span style="font-size:85%;"><span style="font-family:trebuchet ms;"> $TempSelection [$SelectionCounter] = $FirstObject;</span><br /><span style="font-family:trebuchet ms;"> $TempSelection [$SelectionCounter+1] = $Duplicate;</span><br /><span style="font-family:trebuchet ms;"> $TempSelection [$SelectionCounter+2] = $SecondObject;</span><br /><span style="font-family:trebuchet ms;"> $TempSelection [$SelectionCounter+3] = $Duplicate;</span><br /><br /><br /><span style="font-family:trebuchet ms;"> $CurrentNumber = $CurrentNumber+2;</span><br /><span style="font-family:trebuchet ms;"> $SelectionCounter = $SelectionCounter + 4;</span><br /><span style="font-family:trebuchet ms;"> $SquareCounter++;</span><br /><span style="font-family:trebuchet ms;"> } while ($CurrentNumber < $SelSize); currentTime $i; $Selection = $TempSelection; $SelSize = size($Selection); if ($SelSize > 100) {</span><br /><span style="font-family:trebuchet ms;"> for ($s = 0; $s < selsize =" 100;" iii =" 0;" sizejump =" size($jump);" nicklambert = "nicklambert" nicklambertsg = "nicklambert" nicklambertoutcolor = "nicklambert" nicklambertsgss = "nicklambert" nicklamberttrans = "nicklambert" iiiend =" $iii" iiiend2 =" $iii" iii="$iii" i="0;" seriessize =" size($series);" s =" 0;" curshader =" $Shader[0];"> </span></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-87800994177708701092008-03-05T03:56:00.000-08:002008-06-21T13:27:59.998-07:00Next up is MEL!!!<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_DACBIEbkSBY/R86RThkA0dI/AAAAAAAAAGI/CUwZMVMcNlo/s1600-h/pSpheres.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_DACBIEbkSBY/R86RThkA0dI/AAAAAAAAAGI/CUwZMVMcNlo/s400/pSpheres.jpg" alt="" id="BLOGGER_PHOTO_ID_5174232786508239314" border="0" /></a><br /><br /><br /><span style="font-family:trebuchet ms;"><br /><br />Nicholas Pisca's workshop at SCI-Arc. I guess MEL is more forgiving than rvb. No Option Explicit, no Dim, and so forth... Sky, Ye, I'm waiting for your scripts too, ok?</span><br /><span style="font-family:trebuchet ms;"><br />The following is a basic script to display certain information from multiple existing geometries. The challenge was to figure out the closest object for each one. I had to use two "integer counters" (<span style="color: rgb(255, 255, 0);">$HCounter</span> and <span style="color: rgb(255, 255, 0);">$JCounter</span>) and the <span style="color: rgb(255, 153, 0);">orange portion</span><span style="color: rgb(255, 153, 0);"> </span>(in the script) was the key for completing this script.</span><br /><br /><br /><br /><br /><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//----------------------------------------------------------------</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//----------------------------------------------------------------</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >// print information and the closest obj for each obj</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//Author: yukie hirashima</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//Contributor: sky</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//Date: 03/05/2008</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//compatibility: Maya8.5</span><span style="font-size:85%;"><br /><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >SelectAll; //don't have to select manually</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >string $Sel[] = `ls-sl` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >int $SelSize = `size($Sel)` ; //Max Array</span><span style="font-size:85%;"><br /></span><span style="font-weight: bold; color: rgb(255, 255, 0);font-family:trebuchet ms;font-size:85%;" >int $JCounter = 0;</span><span style="font-size:85%;"><br /><br /></span><span style="font-weight: bold; color: rgb(255, 255, 0);font-family:trebuchet ms;font-size:85%;" >do {</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > string $closest ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > string $CurrentRef = $Sel[$JCounter] ; </span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $ValScaleX = `getAttr ($Sel[$JCounter] + ".scaleX")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ("\n" ) ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ("\n" ) ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ($Sel[$JCounter] + " Attribute" + "/" + "\n") ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ("Objext name: " + $Sel[$JCounter] + " has an scaleX value of " + $ValScaleX + "\n" ) ;</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $ValRotateY = `getAttr ($Sel[$JCounter] + ".rotateY")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ("Objext name: " + $Sel[$JCounter] + " has an rotateY value of " + $ValRotateY + "\n" ) ; </span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $ValTranslateZ = `getAttr ($Sel[$JCounter] + ".translateZ")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ("Objext name: " + $Sel[$JCounter] + " has an translateZ value of " + $ValTranslateZ + "\n" ) ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > //comparig the closest for each one</span><span style="font-size:85%;"><br /></span><span style="color: rgb(255, 255, 0); font-weight: bold;font-family:trebuchet ms;font-size:85%;" > int $HCounter = 1;</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" >//creating mini array<br />SelectAll; //don't have to select manually<br />select -tgl $CurrentRef ;<br />string $miniSel[] = `ls-sl` ;<br />int $miniSelSize = `size($miniSel)` ; //max array<br /></span><span style="color: rgb(255, 102, 102);font-family:trebuchet ms;font-size:85%;" ></span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > //creating $PreviousDist for the first round </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $XYZVals01[] = `getAttr ($CurrentRef + ".translate")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > vector $XYZVec01 = <<$XYZVals01[0], $XYZVals01[1], $XYZVals01[2]>> ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $XYZVals02[] = `getAttr ($miniSel[$HCounter-1] + ".translate")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > vector $XYZVec02 = <<$XYZVals02[0], $XYZVals02[1], $XYZVals02[2]>> ;</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > $DiffVec = $XYZVec01 - $XYZVec02 ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $PreviousDist = mag($DiffVec) ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > //print ($PreviousDist + "\n") ; //TESTPRINT $PreviousDist</span><span style="font-size:85%;"><br /><br /><br /></span><span style="font-weight: bold; color: rgb(255, 255, 0);font-family:trebuchet ms;font-size:85%;" > do { </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style="color: rgb(255, 102, 0);font-family:trebuchet ms;font-size:85%;" > //creating mini array for each round EXCLUDING </span><span style="color: rgb(255, 102, 0);font-family:trebuchet ms;font-size:85%;" >$CurrentRef </span><span style="color: rgb(255, 102, 0);font-size:85%;" ><br /><br /></span><span style="color: rgb(255, 102, 0);font-family:trebuchet ms;font-size:85%;" > SelectAll; //don't have to select manually</span><span style="color: rgb(255, 102, 0);font-size:85%;" ><br /></span><span style="color: rgb(255, 102, 0);font-family:trebuchet ms;font-size:85%;" > select -tgl $CurrentRef ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > string $miniSel[] = `ls-sl` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > int $miniSelSize = `size($miniSel)` ; //Max Array</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print (" now vs. " + $miniSel[$HCounter-1] + ": "); //TESTPRINT comparison</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > //get a distance from vector</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $XYZVals01[] = `getAttr ($CurrentRef + ".translate")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > vector $XYZVec01 = <<$XYZVals01[0], $XYZVals01[1], $XYZVals01[2]>> ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $XYZVals02[] = `getAttr ($miniSel[$HCounter-1] + ".translate")` ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > vector $XYZVec02 = <<$XYZVals02[0], $XYZVals02[1], $XYZVals02[2]>> ;</span><span style="font-size:85%;"><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > $DiffVec = $XYZVec01 - $XYZVec02 ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > float $CurrentDist = mag($DiffVec) ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ("Distance btw " + $CurrentRef + " & " + $miniSel[$HCounter-1] + " is " + $CurrentDist + "\n") ;</span><span style="font-size:85%;"><br /><br /><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > if ($CurrentDist <= $PreviousDist) { </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > $closest = $miniSel[$HCounter-1] ;</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > //print ("\n" + $CurrentDist) ; //TESTPRINT $CurrentDist</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > $PreviousDist= $CurrentDist ; // prepareing for the next round</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > }</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > </span><span style="font-size:85%;"><br /></span><span style="font-weight: bold; color: rgb(255, 255, 0);font-family:trebuchet ms;font-size:85%;" > $HCounter++ ;</span><span style="font-size:85%;"><br /></span><span style="font-weight: bold; color: rgb(255, 255, 0);font-family:trebuchet ms;font-size:85%;" > } while ($HCounter < $SelSize);</span><span style="font-size:85%;"><br /></span><span style=";font-family:trebuchet ms;font-size:85%;" > print ($CurrentRef + " is closest to " + $closest + "\n") ;</span><span style="font-size:85%;"><br /><br /></span><span style="color: rgb(255, 255, 0); font-weight: bold;font-family:trebuchet ms;font-size:85%;" > $JCounter++ ; </span><span style="font-size:85%;"><br /></span><span style="color: rgb(255, 255, 0); font-weight: bold;font-family:trebuchet ms;font-size:85%;" >} while ($JCounter < $SelSize) ; </span><span style=";font-family:trebuchet ms;font-size:85%;" >// ----------------------------------------------------------------</span><span style="font-size:85%;"><br /></span><span style="font-family:trebuchet ms;"><span style="font-size:85%;">// ----------------------------------------------------------------<br /></span><br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-19079821247806966982008-02-12T23:53:00.001-08:002008-07-13T17:51:39.106-07:00Ready for Another Lattice?<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_DACBIEbkSBY/SHqjEi1LQvI/AAAAAAAAAIc/SCLinzdVMjs/s1600-h/_Lattice002.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp1.blogger.com/_DACBIEbkSBY/SHqjEi1LQvI/AAAAAAAAAIc/SCLinzdVMjs/s320/_Lattice002.jpg" alt="" id="BLOGGER_PHOTO_ID_5222666016354157298" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_DACBIEbkSBY/R7KjLidCDfI/AAAAAAAAAF4/RoYqdH_zcb4/s1600-h/polyline.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp0.blogger.com/_DACBIEbkSBY/R7KjLidCDfI/AAAAAAAAAF4/RoYqdH_zcb4/s320/polyline.jpg" alt="" id="BLOGGER_PHOTO_ID_5166371141169843698" border="0" /></a><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Here is another practical script for making physical models. I have to explode polylines manually first, then select the segment curves in order to layout for print (with little markers). Since "orient curve" command keeps working in a Loop, I have to Esc out the script, or simply <span style="color: rgb(255, 255, 0);">reDim "i" manually</span> for every round.<br /><br /><br /><br />Option Explicit<br /><br />layoutPolyline<br />Sub layoutPolyline<br /><br />Dim strLine01, strLine02, strLineSave, i, j, arrReference, arrTarget<br />Dim arrCurve01S, arrCurve01E, arrCurve02S, arrCurve02E<br />Dim arrTarget1, arrTarget2, strMarker<br /><span style="font-weight: bold; color: rgb(255, 255, 0);">i = 4</span><br />j = i + 0.75<br /><br />'select an initial line to duplicate and hide<br />strLine01 = Rhino.GetObject ("select a line", 4)<br />strLineSave = Rhino.CopyObject (strLine01)<br />Call Rhino.HideObject(strLineSave)<br /><br />'orient the line<br />arrCurve01S = Rhino.CurveStartPoint (strLine01)<br />arrCurve01E = Rhino.CurveEndPoint (strLine01)<br /><br />arrReference = Array (arrCurve01S,arrCurve01E)<br />arrTarget1 = Array (0,-i, 0)<br />arrTarget2 = Array (99999,-i, 0)<br />arrTarget = Array (arrTarget1,arrTarget2)<br /><br />strLine01 = Rhino.OrientObject (strLine01, arrReference, arrTarget)<br />strMarker = Rhino.AddLine (arrTarget1, Array(0,-j,0))<br /><br /><br /><br />'select the succeding lines in order<br />Do<br />'duplicate and hide<br />strLine02 = Rhino.GetObject ("select the next line", 4)<br />strLineSave = Rhino.CopyObject (strLine02)<br />Call Rhino.HideObject(strLineSave)<br /><br />'orient lines<br />arrCurve02S = Rhino.CurveStartPoint (strLine02)<br />arrCurve02E = Rhino.CurveEndPoint (strLine02)<br /><br />arrReference = Array (arrCurve02S,arrCurve02E)<br />arrTarget1 = Array (0,-i, 0)<br />arrTarget2 = Array (99999,-i, 0)<br />arrTarget = Array (arrTarget1,arrTarget2)<br /><br />strLine02 = Rhino.OrientObject (strLine02, arrReference, arrTarget)<br /><br />arrCurve01S = Rhino.CurveStartPoint (strLine01)<br />arrCurve01E = Rhino.CurveEndPoint (strLine01)<br />arrCurve02S = Rhino.CurveStartPoint (strLine02)<br />arrCurve02E = Rhino.CurveEndPoint (strLine02)<br /><br />Call Rhino.MoveObject (strLine02, arrCurve02S, arrCurve01E)<br />Call Rhino.CopyObject (strMarker, arrTarget1, arrCurve01E)<br /><br />strLine01 = strLine02<br />Loop<br /><br />End Sub<br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-75593840184980299682008-02-05T21:36:00.000-08:002008-04-22T11:56:01.545-07:00Something Flowerly<a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_DACBIEbkSBY/R6lHvPU_FTI/AAAAAAAAAFw/baJeln0boXE/s1600-h/scriptVector.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_DACBIEbkSBY/R6lHvPU_FTI/AAAAAAAAAFw/baJeln0boXE/s320/scriptVector.jpg" alt="" id="BLOGGER_PHOTO_ID_5163737324650960178" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;"><br /><br />Recent progress in rvb. As it's explained in script, </span><br /><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >1. create sphere in spiral, and scale accordingly</span><br /><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >2. draw 2d line, rotate, and move</span><br /><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >3. rotate sphere in 3D</span><br /><br /><span style="font-family:trebuchet ms;">thats all. Enjoy.</span><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;">Option Explicit<br /><br /></span><span style="font-family:trebuchet ms;">addVector()</span><br /><span style="font-family:trebuchet ms;">Sub addVector()</span><br /><br /><span style="font-family:trebuchet ms;"> Dim arrCoordinate(2), arrPoint(), arrSphere(), arrScaleSphere()</span><br /><span style="font-family:trebuchet ms;"> Dim arrLine(), arrSt(2), arrEd(2), arrRotateLine(), dblAngle </span><br /><span style="font-family:trebuchet ms;"> Dim arrFinSphere(), arrAxis(), arrLineEd()</span><br /><span style="font-family:trebuchet ms;"> Dim i, t, pi, arrScale</span><br /><span style="font-family:trebuchet ms;"> Dim A, B, C</span><br /><span style="font-family:trebuchet ms;"> i = 0</span><br /><span style="font-family:trebuchet ms;"> dblAngle = 30 </span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);font-family:trebuchet ms;" >For</span><span style="font-family:trebuchet ms;"> t = -5 To 6 Step 0.05</span><br /><br /><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >'create sphere in spiral, and scale accordingly '''''''''''''''''''''''</span><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >'''''''''''''''''''''''''''''''''''''''''''''''</span><br /><span style="font-family:trebuchet ms;"> A = 1</span><br /><span style="font-family:trebuchet ms;"> B = 1</span><br /><span style="font-family:trebuchet ms;"> C = t+5</span><br /><span style="font-family:trebuchet ms;"> arrScale = Array(A, B, C)</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> arrCoordinate(0) = t*Sin(5*t)</span><br /><span style="font-family:trebuchet ms;"> arrCoordinate(1) = t*Cos(5*t)</span><br /><span style="font-family:trebuchet ms;"> arrCoordinate(2) = t</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> 'ReDim Preserve arrPoint(i)</span><br /><span style="font-family:trebuchet ms;"> 'arrPoint(i) = Rhino.AddPoint(arrCoordinate) 'don't need a string of point to draw a sphere</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrSphere(i)</span><br /><span style="font-family:trebuchet ms;"> arrSphere(i) = Rhino.AddSphere(arrCoordinate, 0.25)</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrScaleSphere(i)</span><br /><span style="font-family:trebuchet ms;"> arrScaleSphere(i) = Rhino.ScaleObject(arrSphere(i), arrCoordinate, arrScale)</span><br /><span style="font-family:trebuchet ms;"> </span><br /><br /><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >'draw 2d line, rotate, and move ''''''''''''''''''''''''''''''''''''''''''''''''</span><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</span><br /><span style="font-family:trebuchet ms;"> arrSt(0) = arrCoordinate(0) </span><br /><span style="font-family:trebuchet ms;"> arrSt(1) = arrCoordinate(1) </span><br /><span style="font-family:trebuchet ms;"> arrSt(2) = 0</span><br /><span style="font-family:trebuchet ms;"> arrEd(0) = 0 </span><br /><span style="font-family:trebuchet ms;"> arrEd(1) = 0</span><br /><span style="font-family:trebuchet ms;"> arrEd(2) = 0</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrLine(i)</span><br /><span style="font-family:trebuchet ms;"> arrLine(i) = Rhino.AddLine(arrSt, arrEd)</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrRotateLine(i)</span><br /><span style="font-family:trebuchet ms;"> arrRotateLine(i) = Rhino.RotateObject(arrLine(i), arrSt, 90)</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> Call Rhino.MoveObject (arrLine(i), arrSt, arrCoordinate)</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >'rotate sphere in 3d '''''''''''''''''''''''</span><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >''''''''''''''''''''''''''''''''''''''''''''''''''''''''</span><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >'''''''''''''''''''''''''''''''''''''''''''''</span><span style="color: rgb(255, 204, 204);font-family:trebuchet ms;" >''''''''''''''' </span><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrLineEd(i)</span><br /><span style="font-family:trebuchet ms;"> arrLineEd(i) = Rhino.CurveEndPoint (arrLine(i))</span><br /><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrAxis(i)</span><br /><span style="font-family:trebuchet ms;"> arrAxis(i)= Rhino.VectorCreate (arrCoordinate, arrLineEd(i))</span><br /><span style="font-family:trebuchet ms;"> </span><br /><span style="font-family:trebuchet ms;"> ReDim Preserve arrFinSphere(i) </span><br /><span style="font-family:trebuchet ms;"> arrFinSphere(i) = Rhino.RotateObject (arrScaleSphere(i), arrCoordinate, dblAngle, arrAxis(i))</span><br /><br /><span style="color: rgb(255, 255, 0);font-family:trebuchet ms;" > i = i+1</span><br /><span style="color: rgb(255, 255, 0); font-weight: bold;font-family:trebuchet ms;" >Next</span><br /><br /><span style="font-family:trebuchet ms;">End Sub<br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-62220103492065618862007-11-26T17:27:00.000-08:002008-07-13T17:52:53.077-07:00orientCurve<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_DACBIEbkSBY/SHqjUtvwJ7I/AAAAAAAAAIk/us_QBt5BXss/s1600-h/_Lattice001.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_DACBIEbkSBY/SHqjUtvwJ7I/AAAAAAAAAIk/us_QBt5BXss/s320/_Lattice001.jpg" alt="" id="BLOGGER_PHOTO_ID_5222666294162106290" border="0" /></a><br /><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />The following is the script to construct this mess. I modeled a polygon lattice in Maya with multiple deformer. In Rhino, the script allows me to select those lines in order to lay them out. I printed those lines and cut wood sticks accordingly.<br /><br />NO measuring! Saved my ass.<br /><br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_DACBIEbkSBY/R0t1RsvwdgI/AAAAAAAAAFc/wx-jdVLHpRk/s1600-h/ScreenShot014.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_DACBIEbkSBY/R0t1RsvwdgI/AAAAAAAAAFc/wx-jdVLHpRk/s320/ScreenShot014.jpg" alt="" id="BLOGGER_PHOTO_ID_5137328746875876866" border="0" /></a><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Option Explicit<br />Sub orientCurve<br /><br />Dim strLine, i, arrReference, arrTarget<br />Dim strCurveS, strCurveE, strTarget1, strTarget2<br />i = 4<br /><br />Do<br /><br />'select lines in order<br />strLine = Rhino.GetObject ("select a line", 4)<br /><br />'orient lines<br />strCurveS = Rhino.CurveStartPoint (strLine)<br />strCurveE = Rhino.CurveEndPoint (strLine)<br /><br />arrReference = Array (strCurveS,strCurveE)<br />strTarget1 = Array (0,-i, 0)<br />strTarget2 = Array (99999,-i, 0)<br />arrTarget = Array (strTarget1,strTarget2)<br /><br />i = i + 0.25<br />Call Rhino.OrientObject (strLine, arrReference, arrTarget)<br /><br />Loop<br /><br />End Sub<br />orientCurve<br /><br /><br /></span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.comtag:blogger.com,1999:blog-3423175248222521930.post-32831415812861606692007-10-15T19:34:00.000-07:002008-04-22T11:55:44.955-07:00Population Script<a style="font-family: trebuchet ms;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_DACBIEbkSBY/RxQjsmHY6dI/AAAAAAAAAFM/t1oBsbNF1j8/s1600-h/poulate.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp0.blogger.com/_DACBIEbkSBY/RxQjsmHY6dI/AAAAAAAAAFM/t1oBsbNF1j8/s320/poulate.jpg" alt="" id="BLOGGER_PHOTO_ID_5121757925279853010" border="0" /></a><br /><span style="font-family:trebuchet ms;"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />This Script takes a bunch of lines and populates another curve to them. Recommended for lasercut.</span><br /><br /><br /><br /><br /><br /><span style="font-family:trebuchet ms;">Option Explicit</span><br /><br /><span style="font-family:trebuchet ms;">Call Populate()</span><br /><span style="font-family:trebuchet ms;">Sub Populate()</span><br /><br /><span style="font-family:trebuchet ms;"> Dim Object, ArrLines, i, Popstart, PopEnd, RefPoints, strScale, strOptions, RefObject</span><br /><br /><span style="font-family:trebuchet ms;"> strOptions = Array ("y", "n")</span><br /><br /><br /><span style="font-family:trebuchet ms;"> Object = Rhino.GetObject ("Select Populate Object", 4)</span><br /><span style="font-family:trebuchet ms;"> RefObject = Rhino.GetObject ("Select Reference line for Population", 4)</span><br /><span style="font-family:trebuchet ms;"> ArrLines = Rhino.GetObjects ("Select target Curves", 4)</span><br /><span style="font-family:trebuchet ms;"> strScale = Rhino.GetString ("Do you want to Scale", "y", strOptions)</span><br /><br /><span style="font-family:trebuchet ms;"> Popstart = Rhino.CurveStartPoint(RefObject)</span><br /><span style="font-family:trebuchet ms;"> PopEnd = Rhino.CurveEndPoint(RefObject)</span><br /><span style="font-family:trebuchet ms;"> RefPoints = Array(Popstart, Popend)</span><br /><br /><span style="font-family:trebuchet ms;"> For i = 0 To UBound(arrLines)</span><br /><span style="font-family:trebuchet ms;"> Call Copypop(Object, arrlines(i), Refpoints, strScale)</span><br /><span style="font-family:trebuchet ms;"> Call Rhino.DeleteObject(arrlines(i))</span><br /><span style="font-family:trebuchet ms;"> Next</span><br /><br /><span style="font-family:trebuchet ms;">End Sub </span><br /><br /><br /><span style="font-family:trebuchet ms;">Function CopyPop(Object, Target, Refpoints, strScale) </span><br /><br /><span style="font-family:trebuchet ms;"> Dim startPoint, endPoint, TargetPoint, PopCurve, tempCrv, refDist</span><br /><br /><span style="font-family:trebuchet ms;"> startPoint = Rhino.CurveStartPoint(target)</span><br /><span style="font-family:trebuchet ms;"> endPoint = Rhino.CurveEndPoint(target)</span><br /><span style="font-family:trebuchet ms;"> TargetPoint = Array(startPoint, endPoint)</span><br /><span style="font-family:trebuchet ms;"> refDist = Rhino.Distance (Refpoints(0), RefPoints(1))</span><br /><br /><br /><span style="font-family:trebuchet ms;"> If strScale = "n" Then</span><br /><span style="font-family:trebuchet ms;"> Dim targetDist, scalefactor</span><br /><span style="font-family:trebuchet ms;"> targetDist = Rhino.Distance(TargetPoint(0), TargetPoint(1))</span><br /><span style="font-family:trebuchet ms;"> scalefactor = TargetDist/Refdist </span><br /><span style="font-family:trebuchet ms;"> tempCrv = Rhino.ScaleObject(Object, RefPoints(0),Array(scalefactor,1,1) ,vbTrue) </span><br /><span style="font-family:trebuchet ms;"> PopCurve = Rhino.OrientObject(TempCrv, RefPoints, TargetPoint)</span><br /><br /><span style="font-family:trebuchet ms;"> Else</span><br /><span style="font-family:trebuchet ms;"> PopCurve = Rhino.OrientObject(Object, RefPoints, TargetPoint, 3)</span><br /><span style="font-family:trebuchet ms;"> End If</span><br /><br /><span style="font-family:trebuchet ms;">End Function</span>S-S-S-Shttp://www.blogger.com/profile/05032019268945891071noreply@blogger.com