home *** CD-ROM | disk | FTP | other *** search
- --INSCHAM.UPL
- --This UPL program implements a new GCD command via UPL to insert chamfers.
- --When installed in the VNP command table it will execute just like any other
- --GCD command.
- --Command syntax is:
- --INS CHAM [SIZe <num>] [COLor <num>] [LAYer <num>] [FONt <num>] : <get data>
-
- proc WarnMsg(In String Msg:80)------------------------------------------------
- PrintWin = 12; TextColor(115) --use warning message window and color
- print Msg+'#29##30#', --the 29 and 30 codes clear and remove the window
- PrintWin = 1; TextColor(106) --return to standard window and color
- end proc----------------------------------------------------------------------
-
- proc Main---------------------------------------------------------------------
-
- const integer MaxLines = 30 , MaxLinesP1 = 31, \
- CR = 13, Abort = 3, Colon = 58, Semi = 59
- integer MIBNums(MaxLines), TotEnts = 0, I, EType, OtherEnd, NEnts, \
- NumDigs, SmallEnd, BigEnd, IEnd(MaxLines), IColor, IFont, \
- ILayer
- coord LinEnds(2,MaxLines), NewEnd(MaxLinesP1)
- string Ans1:1, SVal:1
- real LLength, NewL, CSize, R
- boolean FirstPass = True, Selected, DupMIB
-
- --Set up modifiers------------------------------------------------------------
-
- DefineModifier(0, '', ' ', False, 0.0)
- CSize = 1.0; DefineModifier(1, 'SIZe', 'R', False, 1.0)
- SysVarI(1, IColor); DefineModifier(2, 'COLor', 'I', False, Real(IColor))
- SysVarI(2, IFont); DefineModifier(3, 'FONt', 'I', False, Real(IFont))
- SysVarI(3, ILayer); DefineModifier(4, 'LAYer', 'I', False, Real(ILayer))
-
- loop --loop to get modifiers
- exit all when LastChar = Abort or LastChar = CR
-
- if not FirstPass or LastChar <> Colon then
- AskModifiers(0) --get modifier values from user
- exit all when LastChar = Abort or LastChar = CR
- GetModifier(1, Selected, CSize, SVal)
- GetModifier(2, Selected, R, SVal); IColor = Integer(R)
- GetModifier(3, Selected, R, SVal); IFont = Integer(R)
- GetModifier(4, Selected, R, SVal); ILayer = Integer(R)
- EndIf
-
- FirstPass = False --FirstPass flag
-
- loop --loop to put in chamfer(s)
- loop --loop to get at least 2 lines
- TotEnts = 0
- print 'pick lines near end to insert chamfer ',
-
- --get entities to insert a chamfer to, (line ents only)
-
- EntMask(0); EntMask(1) --allow only lines to be picked
- loop
- GetEnt(1, NEnts, MIBNums(TotEnts+1), IEnd(TotEnts+1))
- exit all when LastChar=Abort or (TotEnts=0 and LastChar=CR)
- exit 3 when LastChar = Colon
- exit when NEnts = 0 or LastChar = Semi
- DupMib = False
- loop I = 1 to TotEnts
- if MIBNums(TotEnts+1) = MIBNums(I) then
- DupMIB = True; exit loop
- endif
- end loop
- if not DupMIB then
- TotEnts = TotEnts+1
- verify line EntID(MIBNums(TotEnts)) \
- Ends(LinEnds(1,TotEnts), LinEnds(2,TotEnts))
- endif
- exit when TotEnts = 30
- EndLoop
- exit when TotEnts > 1 --got all the entities we need
- exit 2 when LastChar = Colon --go back to modifier processor
- WarnMsg('<at least 2 lines must be selected, pick some more>')
- EndLoop
-
- --calculate new line end points and chamfer area end points
-
- loop I = 1 to TotEnts
-
- --calculate new end point, which end to modify is determined
- --by which end of the line was digitize closest to
-
- if IEnd(I) = 1 then OtherEnd = 2; else OtherEnd = 1; EndIf
- NewL = VLen(LinEnds(1,I), LinEnds(2,I))-CSize
- NewEnd(I) = (VUnit(LinEnds(IEnd(I),I)-LinEnds(OtherEnd,I)) * \
- Coord(NewL, NewL, NewL)) + LinEnds(OtherEnd,I)
- modify line EntID(MIBNums(I)) Rpnt(True) \ --update the line
- Ends(LinEnds(OtherEnd,I), NewEnd(I)) --in the database
- EndLoop
-
- if TotEnts > 2 then
- TotEnts = TotEnts+1
- NewEnd(TotEnts) = NewEnd(1)
- endif
-
- Insert String verts(TotEnts, NewEnd(1)) rpnt(True) \--put chamfer
- color(IColor) layer(ILayer) font(IFont) --in as a string
- exit all when LastChar = CR --all done
- exit when LastChar = Colon --get new modifiers
- EndLoop
- EndLoop
- end proc
-