Hi, Could anyone give me directions on how to make a smartpart as a sketch? I think we should use the TUBE command but I would like to make sure that:
1) there is the possibility of creating a customizable section (possibility of adding/removing points);
2) there is the possibility of adding/removing points from the path.
Thank for help.
- Forum
- CAD Parametrische Modellierung
- CAD SmartParts
[Frage] Tube
Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen
... now the end of the free service is reached. Finally, deal with the SmartPart language, take a training or hire someone to do whatever you want to program it.
Sí se puede. La única limitación conocida es que la trayectoria solo puede ser poligonal.
If possible. The only known limitation is that the path can only be polygonal.
Anhänge (1)
If possible. The only known limitation is that the path can only be polygonal.
Hi JR, thank you for your example!
Yes, of course it can be done.
Give it a try and see what you can achieve...
A simple example would have been more useful but thanks for the suggestion anyway.
I was expecting that answer but trying things out for yourself is the best way to improve your knowledge and gain confidence.
You could have found the answer to your 2 questions by doing a simple test. It would have taken even less time than writing the message.
And the help functions are there to give the basic explanations.
Thanks to JR for giving this example anyway.
Yes, of course it can be done.
Give it a try and see what you can achieve...
Hi, here one simple example but without code for path of tube (it's complicated for me)
Master-Script
eps=0.00001
x=1
y=2
Parameters-Script
IF GLOB_UI_BUTTON_ID = 1000 THEN
GOSUB "reset"
ENDIF
!!!get insert index
IF GLOB_MODPAR_NAME = "p_ins" THEN
IF p_ins > 0 THEN
i = p_ins
GOSUB "ins_pnt"
ENDIF
!!!reset flag
p_ins = 0
PARAMETERS p_ins = p_ins
ENDIF
!!!get delete index
IF GLOB_MODPAR_NAME = "p_del" THEN
IF p_del > 0 THEN
i = p_del
GOSUB "del_pnt"
ENDIF
!!!reset flag
p_del = 0
PARAMETERS p_del = p_del
ENDIF
END
"reset":
!!!reset point count
p_cnt = 6
PARAMETERS p_cnt = p_cnt
!!!reset point position
REDIM p [ 6 ][ 2 ]
PARAMETERS p = p
p [ 1 ][ x ]= 0
PARAMETERS p [ 1 ][ x ]= p [ 1 ][ x ]p [ 1 ][ y ]= 0
PARAMETERS p [ 1 ][ y ]= p [ 1 ][ y ]
p [ 2 ][ x ]= -REF_POS_A
PARAMETERS p [ 2 ][ x ]= p [ 2 ][ x ]p [ 2 ][ y ]= 0
PARAMETERS p [ 2 ][ y ]= p [ 2 ][ y ]
p [ 3 ][ x ]= -REF_POS_A
PARAMETERS p [ 3 ][ x ]= p [ 3 ][ x ]p [ 3 ][ y ]= hgt - wdt
PARAMETERS p [ 3 ][ y ]= p [ 3 ][ y ]
p [ 4 ][ x ]= -REF_POS_A - wdt
PARAMETERS p [ 4 ][ x ]= p [ 4 ][ x ]p [ 4 ][ y ]= hgt - wdt
PARAMETERS p [ 4 ][ y ]= p [ 4 ][ y ]
p [ 5 ][ x ]= -REF_POS_A - wdt
PARAMETERS p [ 5 ][ x ]= p [ 5 ][ x ]p [ 5 ][ y ]= hgt
PARAMETERS p [ 5 ][ y ]= p [ 5 ][ y ]
p [ 6 ][ x ]= 0
PARAMETERS p [ 6 ][ x ]= p [ 6 ][ x ]p [ 6 ][ y ]= hgt
PARAMETERS p [ 6 ][ y ]= p [ 6 ][ y ]!!!reset flag
RETURN
"ins_pnt":
!!!move points above
FOR j = p_cnt + 1 TO i + 1 STEP -1
p [ j ][ x ]= p [ j - 1 ] [ x ]p [ j ][ y ]= p [ j - 1 ] [ y ]PARAMETERS p [ j ][ x ]= p [ j ][ x ],
p [ j ][ y ]= p [ j ][ y ]NEXT j
!!!calc new position
x1 = p [ i ][ x ]y1 = p [ i ][ y ]IF i = p_cnt THEN
x2 = p [ 1 ][ x ]y2 = p [ 1 ][ y ]ELSE
x2 = p [ i + 2 ] [ x ]y2 = p [ i + 2 ] [ y ]ENDIF
cx = x1 + ( x2 - x1 ) / 2
cy = y1 + ( y2 - y1 ) / 2
!!!insert point
p [ i + 1 ] [ x ]= cx
p [ i + 1 ] [ y ]= cy
PARAMETERS p [ i + 1 ] [ x ]= p [ i + 1 ] [ x ],
p [ i + 1 ] [ y ]= p [ i + 1 ] [ y ]!!! increment point count
p_cnt = p_cnt + 1
PARAMETERS p_cnt = p_cnt
RETURN
"del_pnt":
!!!move points above
FOR j = i TO p_cnt - 1
p [ j ][ x ]= p [ j + 1 ] [ x ]p [ j ][ y ]= p [ j + 1 ] [ y ]PARAMETERS p [ j ][ x ]= p [ j ][ x ],
p [ j ][ y ]= p [ j ][ y ]NEXT j
!!!decrement point count
p_cnt = p_cnt - 1
PARAMETERS p_cnt = p_cnt
RETURN
3D-Script
TRANS REF_X / 2 , 0 , 0
ROTZ 90
ROTX 90
GOSUB "prof_hnds"
GOSUB "ins_hnds"
RESTORE 3
GOSUB "put_prof_pnts"
GOSUB "put_tube_pnts"
TUBE p_cnt + 1 , t_cnt , 1 + 2 ,
GET ( NUM_SP )
END
"put_tube_pnts":
t_cnt = 0
PUT -offs_l - 1 , 0 , 0 , 0
PUT -offs_l , 0 , 0 , 0
t_cnt = t_cnt + 2
PUT REF_X + offs_r , 0 , 0 , 0
PUT REF_X + offs_r + 1 , 0 , 0 , 0
t_cnt = t_cnt + 2
RETURN
"put_prof_pnts":
FOR i = 1 TO p_cnt
cx = p [ i ][ x ]cy = p [ i ][ y ]PUT p [ i ][ x ], p [ i ][ y ], 0 !1
NEXT i
PUT p [ 1 ][ x ], p [ 1 ][ y ], 0
RETURN
"prof_hnds":
FOR i = 1 TO p_cnt
cx = p [ i ][ x ]cy = p [ i ][ y ]HANDLE 0 , 0 , 0 , id , p [ i ][ x ], 1
HANDLE cx , cy , 0 , id , p [ i ][ x ], 2
HANDLE -1 , 0 , 0 , id , p [ i ][ x ], 3
HANDLE 0 , 0 , 0 , id , p [ i ][ y ], 1
HANDLE cx , cy , 0 , id , p [ i ][ y ], 2
HANDLE 0 , -1 , 0 , id , p [ i ][ y ], 3
id = id + 1
!!!delete handles only if more than 3 points
IF p_cnt > 3 THEN
HANDLE cx , cy , 0 , id , "p_del" , 10 , i
id = id + 1
ENDIF
NEXT i
RETURN
"ins_hnds":
FOR i = 1 TO p_cnt
x1 = p [ i ][ x ]y1 = p [ i ][ y ]IF i = p_cnt THEN
x2 = p [ 1 ][ x ]y2 = p [ 1 ][ y ]ELSE
x2 = p [ i + 1 ] [ x ]y2 = p [ i + 1 ] [ y ]ENDIF
cx = x1 + ( x2 - x1 ) / 2
cy = y1 + ( y2 - y1 ) / 2
HANDLE cx , cy , 0 , id , "p_ins" , 10 , i
id = id + 1
IF PREV_MODE THEN
LINE x1 , y1 , 0 , x2 , y2 , 0
ENDIF
NEXT i
IF PREV_MODE THEN
LINE p [ p_cnt ] [ x ], p [ p_cnt ] [ y ], 0 , p [ 1 ][ x ], p [ 1 ][ y ], 0
ENDIF
RETURN
The last point of your section (profile) must have "-1" for "s", not "0".
The first and last points for the path of TUBE can be the same as the second and the before last points.
... wich "s"? I don't understand
The syntax for Tube function is:
TUBE n , m , mask , u1 , w1 , s1 , ... , un , wn , sn , x1 , y1 , z1 , angle1 , ... , xm , ym , zm , anglem
I talk about these "s" values.