Roscoe Posted February 20, 2009 Share Posted February 20, 2009 Does anyone do any type of 3D motion simulation? For example, showing how mechanisms move, like a piston, connecting rod and crankshaft. Is there any way to do this in Vectorworks? Quote Link to comment
islandmon Posted February 20, 2009 Share Posted February 20, 2009 In your Vectorworks Application directory there are examples which include the scripting to make it happen. >Extras>Goodies>Rotating Gears.sta Quote Link to comment
GWS Posted February 20, 2009 Share Posted February 20, 2009 Unfortunately VW doesn't do what you're asking for. May I suggest you take a look at Solidworks or Inventor. I've used both and prefer Solidworks although they are quite similar in many ways. Both programs are expensive compared to VW but they do what they do very well. Quote Link to comment
islandmon Posted February 21, 2009 Share Posted February 21, 2009 FYI, this is the script for the rotating cam example: _______ Procedure RotateCam; {*******************************************} {* ?2003, Nemetschek, N.A. *} {* Developed by Tom Urie *} {*******************************************} CONST kArmLength = 2.4570; { pivot arm length } kArmAngle0 = 31.13; { initial angle of pivot arm } kArmAngle = 0.1282; { rotation of pivot arm per degree of cam rotation } kXc = 0.0; { x center of cam } kYc = -0.2010; { y center of cam } kXL = 2.4259; { x center of pivot arm } kYL = 5.3870; { y center of pivot arm } kRroller = 0.625; { radius of roller } kMaxA = 11; { maximum a } kMaxSpeed = 120; { maximum speed } kDia = 0.750; { spring diameter } kLength0 = 4.000; { initial spring length } kNumCoils = 12; { number of coils in the spring } kXS = 7.6880; { x origin of spring } kYS = 3.3137; { y origin of spring } VAR armAngle : REAL; { angle of the pivot arm from kArmAngle0 } theta : REAL; { total rotation of cam } xF, yF : REAL; { follower center } aCam : INTEGER; { angular rotation of cam per repetition } dialogID : INTEGER; { dialog id number } exitState : INTEGER; { value returned by the dialog } j : INTEGER; { used to keep track of which direction the follower is moving } speed : INTEGER; { relative speed } camH : HANDLE; { handle to the cam } followerH : HANDLE; { handle to the follower } pivotH : HANDLE; { handle to the pivot arm } recordH : HANDLE; { handle to the record that stores the last value of 'j' } rollerH : HANDLE; { handle to the roller } springH : HANDLE; { handle to the spring } dialogOK : BOOLEAN; { flag - dialog is ok } {======================================================================} FUNCTION defineDialog : INTEGER; VAR dialogID : INTEGER; BEGIN dialogID := CreateLayout ( 'Rotating Cam', False, ' Start The Cam ', 'Cancel' ); {* Create the control items *} CreateGroupBox( dialogID, 3, 'Speed', True ); CreateStaticText( dialogID, 4, 'Slow', -1 ); CreateControl( dialogID, 5, 3, '', kMaxSpeed ); CreateStaticText( dialogID, 6, 'Fast', -1 ); {CreatePushButton( dialogID, 7, 'Start << Hit any key to stop >>' );} {* Position the control items *} SetFirstLayoutItem( dialogID, 3 ); SetFirstGroupItem( dialogID, 3, 4 ); SetRightItem( dialogID, 4, 5, 0, 0 ); SetRightItem( dialogID, 5, 6, 0, 0 ); {SetBelowItem( dialogID, 3, 7, 0, 1 );} {* Align the button and the group box to the right side *} AlignItemEdge( dialogID, 3, 1, 100, 0 ); AlignItemEdge( dialogID, 7, 1, 100, 0 ); defineDialog := dialogID; END; { of defineDialog } {======================================================================} PROCEDURE displayDialog( VAR item : LONGINT; data : LONGINT ); BEGIN CASE item OF SetUpDialogC: BEGIN speed := ( aCam - 1 ) * kMaxSpeed / ( kMaxA - 1 ); SetControlData( dialogID, 5, speed ); END; 1: BEGIN END; 5: BEGIN GetControlData( dialogID, 5, speed ); aCam := ( ( kMaxA - 1 ) * speed / kMaxSpeed ) + 1; END; {7: item := 1;} END; { of CASE item } END; { of displayDialog } {======================================================================} PROCEDURE DrawSpring( dia, length : REAL; numCoils : INTEGER; x0, y0, alpha : REAL ); VAR pitch : REAL; i : INTEGER; BEGIN pitch := ( length - dia ) / ( numCoils + 0.5 ); Absolute; MoveTo( x0+dia/2, y0 ); Relative; BeginGroup; Arc( -dia/2, dia/2, dia/2, -dia/2, 90, 180 ); Move( 0, -dia/2 ); FOR i := 1 TO numCoils DO BEGIN LineTo( pitch/2, dia ); LineTo( pitch/2, -dia ); END; LineTo( pitch/2, dia ); Arc( -dia/2, 0, dia/2, -dia, 270, 180 ); EndGroup; Absolute; HRotate( LNewObj, x0, y0, alpha ); END; {of DrawSpring} {======================================================================} PROCEDURE RotateTheCam(VAR aCam, j : INTEGER; VAR theta, xF, yF, armAngle : REAL); VAR a : REAL; { temporary variable } aArm : REAL; { angular rotation of pivot arm per repetition } alpha, beta : REAL; { temporary variables } aRoller : REAL; { angular rotation of roller per repetition } dB, dDy : REAL; { temporary variables } delta : REAL; { temporary variable } dy : REAL; { linear movement of follower per repetition } length : REAL; { length of the spring at any given moment } r1 : REAL; { radius of cam under the roller } rRoller : REAL; { radius of roller } xM, yM : REAL; { coordinates of a mouse click } cCode : INTEGER; { key code of key depressed to stop rotation } i : INTEGER; { counter } BEGIN rRoller := kRroller; {length := kLength0;} aArm := aCam * kArmAngle; dy := aCam / 180; REPEAT theta := theta + aCam; yF := yF + j*dy; r1 := yF - rRoller; aRoller := r1 * aCam / rRoller; armAngle := armAngle + j*aArm; a := 2 * kArmLength * Sin( Deg2Rad( armAngle/2 )); beta := 180 - kArmAngle0 + armAngle/2; length := Sqrt (kLength0^2 + a^2 - 2*kLength0*a*Cos (Deg2Rad (beta))); alpha := Rad2Deg( ArcSin( a * sin( Deg2Rad( beta ) ) / length ) ); HRotate( camH, kXc, kYc, aCam ); HRotate( pivotH, kXL, kYL, -j*aArm ); HMove( followerH, 0, j*dy ); HRotate( rollerH, xF, yF, -aRoller ); DelObject( springH ); DrawSpring( kDia, length, kNumCoils, kXS, kYS, -(180 - alpha) ); springH := LNewObj; SetDSelect (springH); SetName( springH, 'Spring' ); Redraw; IF theta >= 180 THEN BEGIN j := -j; delta := theta - 180; IF delta > 0 THEN BEGIN dB := 2 * delta * kArmAngle; dDy := delta / 90; yF := yF + j*dDy; armAngle := armAngle + j*dB; a := 2 * kArmLength * Sin( Deg2Rad( armAngle/2 )); beta := 180 - kArmAngle0 + armAngle/2; length := Sqrt (kLength0^2 + a^2 - 2*kLength0*a*Cos (Deg2Rad (beta))); alpha := Rad2Deg( ArcSin( a * sin( Deg2Rad( beta ) ) / length ) ); HRotate( pivotH, kXL, kYL, -j*dB ); HMove( followerH, 0, j*dDy ); DelObject( springH ); DrawSpring( kDia, length, kNumCoils, kXS, kYS, -(180 - alpha) ); springH := LNewObj; SetDSelect (springH); SetName( springH, 'Spring' ); Redraw; END; theta := delta; END; UNTIL KeyDown( cCode ) | MouseDown (xM, yM); END; {of RotateTheCam} {======================================================================} BEGIN; DselectAll; UnDoOff; camH := GetObject( 'Cam' ); followerH := GetObject( 'Follower' ); pivotH := GetObject( 'Pivot' ); rollerH := GetObject( 'Roller' ); springH := GetObject( 'Spring' ); recordH := GetObject( 'Cam Record' ); {* Get the info stored in the record *} aCam := Str2Num( GetRField( recordH, 'Cam Record', 'aCam' ) ); j := Str2Num( GetRField( recordH, 'Cam Record', 'direction' ) ); theta := Str2Num( GetRField( recordH, 'Cam Record', 'theta' ) ); xF := 0.0000; yF := Str2Num( GetRField( recordH, 'Cam Record', 'Follower Y' ) ); armAngle := Str2Num( GetRField( recordH, 'Cam Record', 'armAngle' ) ); {* Display the dialog and get the info *} dialogID := defineDialog; dialogOK := VerifyLayout( dialogID ); exitState := RunLayoutDialog( dialogID, displayDialog ); IF exitState = 1 THEN BEGIN RotateTheCam (aCam, j, theta, xF, yF, armAngle); {* Save the info to the record *} SetRField( recordH, 'Cam Record', 'aCam', Num2Str( 4, aCam ) ); SetRField( recordH, 'Cam Record', 'direction', Num2Str( 0, j ) ); SetRField( recordH, 'Cam Record', 'theta', Num2Str (4, theta ) ); SetRField( recordH, 'Cam Record', 'Follower Y', Num2Str (4, yF ) ); SetRField( recordH, 'Cam Record', 'armAngle', Num2Str (4, armAngle ) ); END; END; RUN(RotateCam); Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.