Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Options

Spline plus cross sections for loft

jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
Possible to draw a spline (middle line of cross sections) and automatically put rectangles (cross sections, Height/2 and Width/2) from file at given length to make a loft?

Length (cm)	Area (sq cm)	Side Len (cm)	Height/2 (cm)	Top Len (cm)	Width/2 (cm)	Width Flare

0,000000	40,000000	0,000000	3,159558	0,000000	3,165000	Uni
5,000000	40,083559	5,000036	3,178329	5,000061	3,152880	Uni
10,000000	40,334567	10,000061	3,204015	10,000154	3,147189	Uni
15,000000	40,755433	15,000082	3,236758	15,000289	3,147859	Uni
20,000000	41,349412	20,000108	3,276690	20,000477	3,154816	Uni
25,000000	42,121674	25,000146	3,323984	25,000731	3,168011	Uni
30,000000	43,078518	30,000204	3,378817	30,001062	3,187397	Uni
35,000000	44,228031	35,000290	3,441393	35,001486	3,212946	Uni
40,000000	45,579783	40,000411	3,511934	40,002017	3,244636	Uni
45,000000	47,145040	45,000574	3,590683	45,002672	3,282456	Uni
50,000000	48,936975	50,000787	3,677910	50,003469	3,326412	Uni
55,000000	50,970398	55,001058	3,773897	55,004428	3,376509	Uni
60,000000	53,262548	60,001394	3,878969	60,005571	3,432778	Uni
65,000000	55,832253	65,001803	3,993451	65,006922	3,495238	Uni
70,000000	58,701426	70,002295	4,117726	70,008509	3,563946	Uni
75,000000	61,893573	75,002876	4,252171	75,010360	3,638940	Uni
80,000000	65,435890	80,003557	4,397226	80,012509	3,720294	Uni
85,000000	69,357543	85,004346	4,553331	85,014993	3,808066	Uni
90,000000	73,691731	90,005254	4,720986	90,017853	3,902349	Uni
95,000000	78,474432	95,006290	4,900703	95,021133	4,003223	Uni
100,000000	83,745876	100,007465	5,093049	100,024885	4,110793	Uni
105,000000	89,550141	105,008791	5,298619	105,029165	4,225164	Uni
110,000000	95,935771	110,010280	5,518049	110,034036	4,346453	Uni
115,000000	102,956530	115,011945	5,752029	115,039569	4,474792	Uni
120,000000	110,670833	120,013799	6,001275	120,045841	4,610305	Uni
125,000000	119,144066	125,015857	6,266583	125,052942	4,753151	Uni
130,000000	128,446466	130,018134	6,548760	130,060967	4,903465	Uni
135,000000	138,657175	135,020647	6,848717	135,070030	5,061429	Uni
140,000000	149,860991	140,023412	7,167374	140,080250	5,227193	Uni
145,000000	162,152882	145,026448	7,505755	145,091767	5,400951	Uni
150,000000	175,635793	150,029774	7,864926	150,104735	5,582881	Uni
155,000000	190,423393	155,033412	8,246034	155,119326	5,773181	Uni
160,000000	206,640630	160,037384	8,650308	160,135736	5,972060	Uni
165,000000	224,423486	165,041712	9,079037	165,154180	6,179716	Uni
170,000000	243,923649	170,046422	9,533642	170,174906	6,396392	Uni
175,000000	265,304267	175,051540	10,015576	175,198185	6,622291	Uni
180,000000	288,747990	180,057096	10,526458	180,224329	6,857672	Uni
185,000000	314,452496	185,063117	11,067963	185,253683	7,102763	Uni
190,000000	342,636287	190,069636	11,641909	190,286637	7,357820	Uni
195,000000	373,540060	195,076688	12,250248	195,323632	7,623112	Uni
200,000000	407,425320	200,084305	12,895024	200,365161	7,898886	Uni
205,000000	444,584170	205,092529	13,578500	205,411787	8,185443	Uni
210,000000	485,332537	210,101396	14,303020	210,464136	8,483043	Uni
215,000000	530,020335	215,110950	15,071135	215,522918	8,791978	Uni
220,000000	579,034301	220,121235	15,885611	220,588944	9,112560	Uni
225,000000	632,794512	225,132299	16,749339	225,663115	9,445067	Uni
230,000000	691,768416	230,144190	17,665498	230,746468	9,789824	Uni
235,000000	756,469348	235,156961	18,637485	235,840170	10,147149	Uni
240,000000	827,459308	240,170667	19,668917	240,945541	10,517347	Uni
245,000000	905,362275	245,185366	20,763746	246,064088	10,900758	Uni
250,000000	990,866209	250,201120	21,926232	251,197523	11,297725	Uni
255,000000	1084,724787	255,217992	23,160914	256,347779	11,708571	Uni
260,000000	1187,773807	260,236049	24,472743	261,517065	12,133640	Uni
265,000000	1300,940648	265,255364	25,867116	266,707905	12,573306	Uni
270,000000	1425,245543	270,276011	27,349829	271,923163	13,027920	Uni
275,000000	1561,817214	275,298068	28,927173	277,166105	13,497838	Uni
280,000000	1711,908692	280,321616	30,606011	282,440464	13,983435	Uni
285,000000	1876,910081	285,346743	32,393822	287,750511	14,485093	Uni
290,000000	2058,365487	290,373540	34,298771	293,101130	15,003201	Uni
295,000000	2257,992424	295,402102	36,329788	298,497915	15,538161	Uni
300,000000	2477,704176	300,432531	38,496660	303,947279	16,090384	Uni
305,000000	2719,635658	305,464933	40,810139	309,456579	16,660294	Uni
310,000000	2986,173453	310,499421	43,282067	315,034268	17,248330	Uni
315,000000	3279,990862	315,536114	45,925513	320,690060	17,854949	Uni
320,000000	3604,089006	320,575141	48,754950	326,435133	18,480631	Uni
325,000000	3961,845296	325,616635	51,786444	332,282362	19,125880	Uni
330,000000	4357,097343	330,660752	55,038055	338,246682	19,791294	Uni
335,000000	4794,156551	335,707646	58,529752	344,345212	20,477434	Uni
340,000000	5277,956385	340,757497	62,284159	350,597866	21,184987	Uni
345,000000	5814,104227	345,810498	66,326637	357,027620	21,914665	Uni
350,000000	6409,091195	350,866878	70,686264	363,661356	22,667386	Uni
355,000000	7070,345408	355,926886	75,395830	370,530134	23,444086	Uni
360,000000	7806,518389	360,990815	80,493091	377,670314	24,245927	Uni
365,000000	8627,768619	366,059022	86,021839	385,124652	25,074355	Uni
370,000000	9546,003998	371,131908	92,032644	392,943209	25,931027	Uni
372,450000	10000,000000	373,611816	95,002850	396,793485	26,315000	Uni


Comments

  • Options
    Matt_ShieldsMatt_Shields Member Posts: 213 PRO
    edited November 2022
    I could image a FeatureScript accomplishing this.  I'm not a FeatureScript expert, but see the code and picture below.

    FeatureScript 1890;
    import(path : "onshape/std/geometry.fs", version : "1890.0");
    
    annotation { "Feature Type Name" : "Loft Thing" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            // Define the parameters of the feature type
        }
        {
            const zArr = [0, 10, 20, 30, 40];
            const lenArr = [5, 10, 20, 30, 40];
            const heightArr = [5, 15, 30, 45, 60];
            var qArr = [];
            var points = [];
            for (var i in range(0, size(zArr) - 1))
            {
                var sketchId = id + "sketch" + i;
                var sketch1 = newSketchOnPlane(context, sketchId, {
                        "sketchPlane" : plane(vector(0, 0, zArr[i]) * millimeter, vector(0, 0, 1))
                    });
                skRectangle(sketch1, "rectangle"~toString(i), {
                    "firstCorner" : vector(-lenArr[i]/2*millimeter, -heightArr[i]/2*millimeter),
                    "secondCorner" : vector(lenArr[i]/2*millimeter, heightArr[i]/2*millimeter)
                });
                qArr = append(qArr, qCreatedBy(id + "sketch" + i, EntityType.FACE));
                skSolve(sketch1);
                points = append(points, vector(0, 0, zArr[i]*millimeter));
            }        
            opFitSpline(context, id + "spline1", { "points" : points });
            opLoft(context, id + "loft1", {
                    "profileSubqueries" : qArr
            });
        });<br>


  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    That's good however in many cases user need a curve for Z (spline) - planes through the points which are perpendicular to the curve .
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited November 2022

    Hi @jacek_zagaja,

    @Matt_Shields example will be the best route. Custom features are the way to go!

    Alternatively, if you don't want to use custom features, you can feature pattern a sketch while driving the width and height with an array variable. This is a neat technique I learned from @alnis. I modified it by using an array and a counter #i to control the array variable per instance of the pattern. @lougallo fixed it for me by rounding #i so that it is acceptable to the array variable. Variables in the studio are more versatile than most people realize.

    • Height values can be stored in the #h variable like this: [1,5,3,1,4] 
    • The counter measures the distance of the square in increments of 1", simulating a counting pattern.
    • #i takes the counter distance, removes the units, and rounds. Like this: round(#counter / in)
    • #height gets the height from the #h array using the #i counter: #h[#i]

    Like this:
    https://cad.onshape.com/documents/b62f463d914f8e6f10144c88/w/ce69cdc2a632b488e8292bb1/e/3c2f3fa0766b642add57addf?renderMode=0&uiState=63764ecc9440cb5c2727bc13




    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    S1monS1mon Member Posts: 2,365 PRO
    Wow. I've done some fun things with patterns before, but it didn't occur to me to use arrays like that. Amazing.
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    edited November 2022
    Michael, thank you very much. Could you please help me making template? Below are height and width ratios. First rectangle is 63x63mm, each line is 5cm further on spline. Total length 372,45cm.

    height ratiowidth ratio
    1.00001.0000
    1.00590.9962
    1.01410.9944
    1.02440.9946
    1.03710.9968
    1.05201.0010
    1.06941.0071
    1.08921.0151
    1.11151.0252
    1.13651.0371
    1.16411.0510
    1.19441.0668
    1.22771.0846
    1.26391.1043
    1.30331.1260
    1.34581.1497
    1.39171.1754
    1.44111.2032
    1.49421.2330
    1.55111.2648
    1.61191.2988
    1.67701.3350
    1.74651.3733
    1.82051.4138
    1.89941.4567
    1.98341.5018
    2.07271.5493
    2.16761.5992
    2.26851.6516
    2.37561.7065
    2.48921.7639
    2.60991.8241
    2.73781.8869
    2.87351.9525
    3.01742.0210
    3.16992.0924
    3.33162.1667
    3.50302.2442
    3.68472.3247
    3.87722.4086
    4.08132.4957
    4.29762.5862
    4.52692.6803
    4.77002.7779
    5.02782.8792
    5.30122.9842
    5.59113.0932
    5.89883.2061
    6.22523.3230
    6.57173.4442
    6.93973.5696
    7.33043.6994
    7.74563.8337
    8.18693.9726
    8.65624.1162
    9.15544.2647
    9.68684.4181
    10.25264.5766
    10.85564.7403
    11.49844.9094
    12.18425.0838
    12.91645.2639
    13.69885.4497
    14.53545.6414
    15.43095.8391
    16.39046.0429
    17.41956.2532
    18.52476.4700
    19.71296.6935
    20.99246.9241
    22.37227.1619
    23.86287.4073
    25.47617.6606
    27.22597.9224
    29.12838.1931
    30.06848.3144
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited November 2022

    @jacek_zagaja, Sure, the easiest way to do this, will be to copy my document I shared with you and use that as a template.

    Here are some of the steps you will need to take:
    • The document is public, so you should be able to click the "Make copy" near the top of the screen when you are viewing the document.
    • The next step, will be to edit the #h array variable, and the #w array variable so that they match your ratios in this table. For #h, it would look something like this [1,1.0059, 1.0141, 1.0244]
    • Edit the #height and #width so that they are using the ratios and your original desired value. For #height it would look like this ( 63mm*#h[#i] )
    • As far as the spline goes, you will need to make sure it has a total length of what you want. There are a few different ways to make a spline, and a few different ways to measure it. If it is a sketch spline, you can use the dimension tool and constrain the length of the spline, I think by clicking the spline itself, or perhaps clicking both ends then the actual spline. If the spline needs to go 3D, you will need to either project two sketch splines together, create a Fit spline with the Fit spline feature, or use a custom feature like Freeform Spline by @Evan_Reese. The spline can be measured afterwards for checking by simply clicking the spline and looking at the bottom right of your screen at the built in measuring tool.



    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    edited November 2022
    First I'm trying to change cross section from triangle to square and having troubles fixing errors. Problem with Transform2. Also can't find how to modify spacing between planes.

    https://cad.onshape.com/documents/f731f72d61c17cddbb926a98/w/7b4c61ca45fb486f06b63c45/e/0a1fd423fa68cb7cc0c2a329?renderMode=0&uiState=637a38d307ac1d328b7388cd

    I could make circles to work but now lost the track and I don't know how it works - Transform 2 and Curve Pattern 2.
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited November 2022

    The spacing was controlled by the spline length from "Sketch - Path". If it has become too confusing, try copying my template again to start over. 

    Perhaps this custom feature would work better for you, it is still advanced, but not quite as crazy as doing it from scratch in a part studio:
    Variable Section Body by @Konstantin_Sh  



    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    edited November 2022
    Matt's solution is perfect however spline cannot be manipulated:

    https://cad.onshape.com/documents/90116ef313e28f84c8ddd247/w/c3503d19f16862b4aff0d3ea/e/c8c8ad6c4ee2ac90c916c8d3?renderMode=0&uiState=637b8821901f4a490fbc3831

    I'd like to make spiral on smaller end and wrap on larger end.
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    let me know if you are interested in paid job with this
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited December 2022

    I'll send you a pm with some CADSharp info. We can set up a discovery call to see what you need.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited December 2022

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    Michael, thank you so much for taking time on this. Is it possible constrain or measure spline length? Spline length is fixed so that each cross section from array is in right position. Here is edited array version: 

    https://cad.onshape.com/documents/cf89248aacacae072b6e5610/w/8f1ee5f98585f82bd71300b6/e/9c36d9c7b50705e9ffdc5d41?renderMode=0&uiState=63a2e80758b17b206809b5fe
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited December 2022

    Happy to help @jacek_zagaja :)

    If you click the spline, you can see its length with the measure icon at the bottom right of the screen. Also, you can measure it with this tool Measure Value by @Konstantin_Sh.

    If the spline is a sketch spline you can use the dimension tool directly on it to constrain the length:


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    In your example above you edit 2D spline while we have 3D spline (freeform spline). Maybe better change 3D spline to 2D spline then?
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,716 PRO
    edited December 2022

    If 2D works for your needs, then yes.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    jacek_zagajajacek_zagaja Member Posts: 46 ✭✭
    I'll try to convert. It's easier with 2D spline - control points and tangency.
Sign In or Register to comment.