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.
TUBE n , m , mask , u1 , w1 , s1 , ... , un , wn , sn , x1 , y1 , z1 , angle1 , ... , xm , ym , zm , anglem
I talk about these "s" values.
Thank you Bertrand for clarification. Now I undurstand.
Now the problem is write the code for TUBE with possibility of add or delete vertices
Tienes el código en el SMT que subí en el mensaje anterior.
You have the code in the SMT that I uploaded in the previous message.
You have the code in the SMT that I uploaded in the previous message.
Thank you for precisation JR. However, is it possible to add/delete the TUBE point in your smt? ...I don't think so. It seems to me that you can only move the points of the TUBE.
Se pueden insertar y eliminar puntos tanto en el recorrido como en el perfil. Además, se pueden mover los segmentos. Uso pinzamientos superpuestos. Para activar los de INSER y DELETE hay que pulsar la tecla MAY. El "HINT" de pinzamiento iforma de ello.
Points can be inserted and deleted on both the route and the profile. Additionally, the segments can be moved. I use overlapping grips. To activate INSER and DELETE you must press the SHIFT key. The "HINT" grip informs you of this.
Points can be inserted and deleted on both the route and the profile. Additionally, the segments can be moved. I use overlapping grips. To activate INSER and DELETE you must press the SHIFT key. The "HINT" grip informs you of this.
Thanks JR for the clarification. For me, in your smt the add/delete point command works for profile points but not for tube points. I don't no.
Quotato da: Bertrand_CHi Danilos,
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
Here a new code 3D...The tube handle point it's created in 0,0 but the beam don't move.
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 )
GOSUB "prof_hnds_tu"
GOSUB "put_prof_pnts_tu"
END
"put_tube_pnts":
t_cnt = 0
PUT -1 , 0 , 0 , 0
PUT 0 , 0 , 0 , 0
t_cnt = t_cnt + 2
PUT REF_X / 2 , 0 , 0 , 0
PUT REF_X / 2 + 1 , 0 , 0 , -1
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
"prof_hnds_tu":
FOR i = 1 TO tu_cnt
cx = t [ i ][ x ]cy = t [ i ][ y ]HANDLE 0 , 0 , 0 , id , t [ i ][ x ], 1
HANDLE cx , cy , 0 , id , t [ i ][ x ], 2
HANDLE -1 , 0 , 0 , id , t [ i ][ x ], 3
HANDLE 0 , 0 , 0 , id , t [ i ][ y ], 1
HANDLE cx , cy , 0 , id , t [ i ][ y ], 2
HANDLE 0 , -1 , 0 , id , t [ i ][ y ], 3
id = id + 1
!!!delete handles only if more than 3 points
IF tu_cnt > 3 THEN
HANDLE cx , cy , 0 , id , "tu_del" , 10 , i
id = id + 1
ENDIF
NEXT i
RETURN
"put_prof_pnts_tu":
FOR i = 1 TO tu_cnt
cx = t [ i ][ x ]cy = t [ i ][ y ]PUT t [ i ][ x ], t [ i ][ y ], 0 !1
NEXT i
PUT t [ 1 ][ x ], t [ 1 ][ y ], 0
RETURN
Disculpa, Danilos. Aporté una verión preliminar del SMT que no se comprta como se esperaba.
Adjunto la versión corregida. Ahora sí se pueden añadir y suprimir puntos tanto del perímetro como del recorrido.
Sorry, Danilos. I provided a preliminary version of the SMT that did not behave as expected. I attach the corrected version. Now you can add and delete points from both the perimeter and the route.
Anhänge (1)
Allego la versione corretta. Ora puoi aggiungere ed eliminare punti sia dal perimetro che dal percorso.
Scusa, Danilos. Ho fornito una versione preliminare dell'SMT che non si è comportata come previsto. Allego la versione corretta. Ora puoi aggiungere ed eliminare punti sia dal perimetro che dal percorso.
Thank you JR for new smt. Now it seems to work but we need to remove the error in the second line 3D script. I don't know what this second line code was for.
AUX_MODE 1
POINT 0,0,0,1,50
!new second line
!POINT 0,0,0,1,50
Adjunto la versión corregida. Ahora sí se pueden añadir y suprimir puntos tanto del perímetro como del recorrido.
Sorry, Danilos. I provided a preliminary version of the SMT that did not behave as expected. I attach the corrected version. Now you can add and delete points from both the perimeter and the route.
Hi, do you know how to ensure that the attachment point of the smt is always at the starting point of the solid?
Adjunto la versión corregida. Ahora sí se pueden añadir y suprimir puntos tanto del perímetro como del recorrido.
Sorry, Danilos. I provided a preliminary version of the SMT that did not behave as expected. I attach the corrected version. Now you can add and delete points from both the perimeter and the route.
I JR, have you ever done a slope test (similar to the attached sketch)?
In this case I noticed that the smt behaves incorrectly (the sloping shape turns around).