VM8 Input Listing


/COM,ANSYS MEDIA REL. 2024R2 (05/10/2024) REF. VERIF. MANUAL: REL. 2024R2
/VERIFY,VM8
/TITLE, VM8, MACRO TO CALCULATE DISTANCES BETWEEN POINTS
*CREATE,MAC
LENGTH              ! LABEL FOR THIS BLOCK IN THE USER FILE
!
!       THIS BLOCK IN THE USER FILE CALCULATES THE STRAIGHT LINE
!       DISTANCE BETWEEN TWO POINTS IN SPACE DEFINED BY EITHER
!       KEYPOINTS OR NODES ( CONTROLLED BY ARG1 ).  OTHER INPUT
!       AND OUTPUT ARGUMENTS ARE DEFINED BELOW.
!
!      INPUT-    ARG1 == IF ZERO, ARG2 AND ARG3 REPRESENT NODES (DEFAULT)
!                     == IF NONZERO, ARG2 AND ARG3 REPRESENT KEYPOINTS
!                ARG2 == NUMBER OF THE FIRST NODE OR KEYPOINT
!                ARG3 == NUMBER OF THE SECOND NODE OR KEYPOINT
!
!      OUTPUT-   PDIS == EXTERNAL PARAMETER ASSIGNED WITH THE DISTANCE VALUE 
!
!
!      NOTES:    1. "NORMALLY" THIS BLOCK WOULD ALREADY EXIST IN A LOCALLY
!                   ATTACHED USER FILE, AND WOULDN'T REQUIRE THE "*CREATE"
!                   OPERATION TO MAKE IT.
!                2. THE CHARACTER ":" USED IN THE FIRST COLUMN OF AN ANSYS
!                   INPUT LINE HAS THE EFFECT OF MAKING THE ENTIRE LINE A
!                   NON-ECHOING COMMENT (USUALLY USED FOR A BRANCHING LABEL).
!
/NOPR                 ! SUPPRESS PRINTOUT DURING MACRO EXECUTION
*GET,AR10,CSYS        ! SAVE CURRENT COORDINATE SYSTEM FOR LATER RESTORATION
CSYS,0                ! CHANGE TO GLOBAL CARTESIAN SYSTEM
*IF,ARG1,EQ,0,THEN
  *GET,ARG4,NX,ARG2     ! RETRIEVE COORDINATE LOCATIONS OF BOTH NODES
  *GET,ARG5,NY,ARG2
  *GET,ARG6,NZ,ARG2
  *GET,ARG7,NX,ARG3
  *GET,ARG8,NY,ARG3
  *GET,ARG9,NZ,ARG3
*ELSE
  *GET,ARG4,KX,ARG2     ! RETRIEVE COORDINATE LOCATIONS OF BOTH KEYPOINTS
  *GET,ARG5,KY,ARG2
  *GET,ARG6,KZ,ARG2
  *GET,ARG7,KX,ARG3
  *GET,ARG8,KY,ARG3
  *GET,ARG9,KZ,ARG3
*ENDIF

!      ----- NOW CALCULATE DISTANCE WITH LOCATIONS OBTAINED ABOVE -----
PDIS=((ARG7-ARG4)*(ARG7-ARG4))+((ARG8-ARG5)*(ARG8-ARG5))
PDIS=SQRT(PDIS+((ARG9-ARG6)*(ARG9-ARG6)))
CSYS,AR10             ! RESTORE ORIGINAL COORDINATE SYSTEM
*IF,ARG1,EQ,0,THEN    ! BRANCH TO KEYPOINT LOGIC IF APPROPRIATE
  /COM LENGTH BETWEEN NODES HAS BEEN DEFINED AS PARAMETER PDIS (FROM USERFILE)
*ELSE
  /COM LENGTH BETWEEN KEYPOINTS DEFINED AS PARAMETER PDIS (FROM USERFILE)
*ENDIF
/GOPR                 ! TURN PRINTOUT BACK ON
*END
/PREP7
C***         ANY BASIC GEOMETRY TEXT
*ULIB,MAC                     ! ASSIGN MACRO LIBRARY FILE
*ABBR,KLEN,*USE,LENGTH,1      ! ASSIGN ABBREVIATIONS FOR "CALLS" TO USERFILE
*ABBR,NLEN,*USE,LENGTH,0
N,1,1.5,2.5,3.5               ! DEFINE TEST NODE AND KEYPOINT LOCATIONS
N,2,-3.7,4.6,-3
K,3,100,0,30
K,4,-200,25,80
KLEN,4,3                      ! USE KEYPOINT DISTANCE PART OF MACRO
LEN1=PDIS
KDIS = LEN1
CSYS,1         ! CYLINDRICAL COORDINATE SYSTEM (SHOULDN'T AFFECT CALCULATION)
NLEN,1,2                      ! USE NODE DISTANCE PART OF MACRO
LEN2=PDIS
NDIS = LEN2
*status,parm

*DIM,LABEL,CHAR,2,2
*DIM,VALUE,,2,3
LABEL(1,1) = 'N1-N2 DI','K3-K4 DI'
LABEL(1,2) = 'STANCE','STANCE'
*VFILL,VALUE(1,1),DATA,8.5849,305.16
*VFILL,VALUE(1,2),DATA,LEN2,LEN1
*VFILL,VALUE(1,3),DATA,ABS(LEN2 / 8.5849 ) , ABS( LEN1 / 305.16 )
/COM
/OUT,vm8,vrt
/COM,------------------- VM8 RESULTS COMPARISON ---------------------
/COM,
/COM,                 |   TARGET   |   Mechanical APDL   |   RATIO
/COM,
*VWRITE,LABEL(1,1),LABEL(1,2),VALUE(1,1),VALUE(1,2),VALUE(1,3)
(1X,A8,A8,'   ',F10.4,'  ',F14.2,'   ',1F15.3)
/COM,----------------------------------------------------------------
/OUT
FINISH
*LIST,vm8,vrt