home *** CD-ROM | disk | FTP | other *** search
- -------------------------------------------------------------------------
- --TOLSTK.UPL
- --Program for tolerance stackup.
- --The user is prompted for a series of linear dimensions. The system
- --will add up the dimensions' nominal values and the tolerances .
- --It will then produce minimum and maximum values.
- --If a comma is entered, the user may then digitize more dimensions
- --which overlap the previous ones in the opposite direction.
- --The difference between the dimensions' nominal values and their
- --tolerances are then produced.
- --
- --This program demonstrates direct database access. It is for advanced
- --UPL programmers only.
- --See Appendix H, Direct Database Access, for more restrictions and
- --other information.
- --====================================================================
- --WARNING:
- -- o Computervision, a division of Prime Computer, Inc., cannot assume
- -- responsibility for a part or drawing which is modified this program.
- -- o The database format and the routines described in this appendix are
- -- subject to change without notice.
- -- o Incorrext use of this information or the included intrinsic
- -- procedures can damage or destroy part databases.
- -- o If this information changes in a new revision, programs which use
- -- this information or the intrinsic procedures may not work and could
- -- possibly damage your part.
- --======================================================================
-
-
- proc main
-
- --D1SubRec -----------------------------------
-
- -- This template holds the record definition for a D1 type
- -- subrecord. It consists of a integer array a series of based
- -- variables. The variables map to appropriate location in the
- -- subrecord.
-
- integer D1SubRec(42) --used in actual data base subrecord
- --access calls as a buffer for the data
-
- coord End1D1 @ D1SubRec + 2,\ -- END 1 of the LDIM
- End2D1 @ D1SubRec + 14 -- END 2 of the LDIM
- real AngleD1 @ D1SubRec + 26 ,\ -- ANGLE
- OffsetD1 @ D1SubRec + 30 ,\ -- OFFSET
- AlphaSizeD1 @ D1SubRec + 34 ,\ -- ASIZE
- Tol1D1 @ D1SubRec + 38 ,\ -- TOL(1)
- Tol2D1 @ D1SubRec + 42 ,\ -- TOL(2)
- TextHgtD1 @ D1SubRec + 46 ,\ -- THGT
- ScaleD1 @ D1SubRec + 50 -- SCL
- integer TypeD1 @ D1SubRec + 62 ,\ -- 1-HOR 2-VER 3-PPNT
- ArrowsInOutD1 @ D1SubRec + 64 ,\ -- 1-AI 2-AO
- DimTypeD1 @ D1SubRec + 66 ,\ -- 1-JIS 2-ANSI
- AlignmentD1 @ D1SubRec + 68 ,\ -- 1-ALIGN 2-NOALIGN
- ArrowTypeD1 @ D1SubRec + 70 ,\ -- ATYPE
- TolTypeD1 @ D1SubRec + 72 ,\ -- TTYPE
- TolPrecD1 @ D1SubRec + 74 ,\ -- TPREC
- CPLusedD1 @ D1SubRec + 76 ,\ -- CPL
- PrecD1 @ D1SubRec + 78 ,\ -- PREC
- CenterD1 @ D1SubRec + 80 -- CENTER
-
- --end of D1SubRec definition-------------------------------
-
- const integer LDim = 6 --entity type
- const integer CR = 13, Comma = 44 --ascii values
-
- integer Type, NumEnts, IEnd, NBytesGot, i, ierr, DummyList(1), Mib
- real MTol, PTol, Dim
- string SrType:2, Nomdim:10
- boolean FirstType
-
- --Allow only linear dimensions to be chosen
- EntMask(0); EntMask(LDim)
-
- --Prompt for and return digitized dimensions
- loop
- print "Ldims to add: ",
- GetEnt(-1, NumEnts, DummyList(1), IEnd)
-
- MTol = 0.0; PTol = 0.0; Dim = 0.0
- FirstType = true
-
- --Go through list of entites, retrieve dimension info from
- --database using the subrecord template and database access
- --intrinsics.
- loop i = 1 to NumEnts
- Mib = BigMibList(i)
- SrType = "D1"
- GetSrI(Mib, SrType, 1, 84, NBytesGot, D1SubRec(1), ierr)
- if ierr = 0 then
- if FirstType then
- Type = TypeD1
- FirstType = false
- endif
-
- --Check for correct type of dimension and then calculate
- --the nominal dimensions and tolerances.
- if Type = TypeD1 then
- PTol = PTol+Tol1D1
- MTol = MTol+Tol2D1
-
- --This direct database access procedure is written
- --especailly for TX subrecords: no template is
- --necessary
- RSubrecTX(Mib,1,ierr,Nomdim)
- if TolTypeD1 = 1 then
- Dim = Dim+(Real(Nomdim)-Tol1D1)
- else
- Dim = Dim+Real(Nomdim)
- endif
- RpntEnt(Mib, 1, ierr)
- else
- print "<Entity types mismatched> ",
- endif
- endif
- end loop
- exit when LastChar = CR or LastChar = Comma or NumEnts = 0
- end loop
-
- --If a comma was entered, calculate the differences of following
- --digitizes, otherwise, skip to end and print results. The process
- --is the same as above...
- if LastChar = Comma then
- loop
- print "Ldims to subtract: ",
- GetEnt(-1, NumEnts, DummyList(1), IEnd)
-
- loop i = 1 to NumEnts
- Mib = BigMibList(i)
- SrType = "D1"
- GetSrI(Mib, SrType, 1, 84, NBytesGot, D1SubRec(1), ierr)
- if ierr = 0 then
- if Type = TypeD1 then
- PTol = PTol-Tol1D1
- MTol = MTol-Tol2D1
- RSubrecTX(Mib,1,ierr,Nomdim)
- if TolTypeD1 = 1 then
- Dim = Dim-(Real(Nomdim)-Tol1D1)
- else
- Dim = Dim-Real(Nomdim)
- endif
- RpntEnt(Mib, 1, ierr)
- else
- print "<Entity types mismatched> ",
- endif
- endif
- end loop
-
- exit when LastChar = CR or NumEnts = 0
- end loop
- endif --LastChar = Comma
-
- --Ouput results
- if LastChar <> CR then print; endif
- print "Total: ",Dim: PrecD1+1
- print "MTOL: ",MTol," , PTOL: ",PTol
- print "Limits: ",Dim-MTol: PrecD1+1,
- print " to ",Dim+PTol: PrecD1+1
-
- end proc