-- Macros for doing circular text. -- Specifies the default center point in X set XCenPt 0 -- Specifies the default center point in Y set YCenPt 0 -- Set the default radius. set CirRad 2 -- Set the default starting angle. set CTStartAng 270 -- Specifies the default ending angle. set CTStopAng 180 -- Sets the default flag for reversing the specified text. set CirTextRotFlg false -- Set the default flag for flattening text. set CTFlattenText false -- Short key for displaying the Circular Text dialog. -- defshort C PostCirTextPanel -- format: defineCirTextPanel -- Defines the panel used for Circular Text. macro defineCirTextPanel ( panel CirText 34 18; panel-text CirText 7 1 "...Circular Text..."; panel-text CirText 2 3 "Circular Dimensions"; panel-textbuf CirText 5 4 26 "X Center Location:" XCenPt 0; panel-textbuf CirText 5 5 26 "Y Center Location:" YCenPt 0; panel-textbuf CirText 5 6 26 "Circle Radius: " CirRad 0; panel-text CirText 2 8 "Text Variables"; panel-textbuf CirText 5 9 26 "Text Start Angle:" CTStartAng 0; panel-textbuf CirText 5 10 26 "Text Stop Angle: " CTStopAng 0; panel-textbuf CirText 5 11 28 "Text String:" CText 1; panel-switch CirText 6 13 "Flatten Text" CTFlattenText; panel-switch CirText 6 14 "Reverse Text Rotation" CirTextRotFlg; panel-button CirText 5 16 8 OK doCirTextMac 1; panel-button CirText 21 16 8 CANCEL (.panel-unpost CirText); ) -- format: PostCirTextPanel -- Post the needed panel for Circular Text. macro PostCirTextPanel ( CTGeomCheck; defineCirTextPanel; .panel-post CirText !x/2 !y/2; ) -- format: CTGeomCheck -- This macro will check the current object to see if it is a segment, an arc -- or circle. Based on the type of entity found we will set the center -- point and the radius. macro CTGeomCheck ( locals arc tmp) ( set arc 0; getnumpts; if (> $NUMPTS 2) then ( if curSegArcEnd then ( set arc 1; ); ); cond (== $NUMPTS 0) return (== $NUMPTS 1) ( set XCenPt `(fmt $MEASURE_PLACES `(what curpt.x)); set YCenPt `(fmt $MEASURE_PLACES `(what curpt.y)); deletept; return; ) (== $NUMPTS 2) ( set tmp `(what curseg); set XCenPt `(fmt $MEASURE_PLACES `(what curpt.x)); set YCenPt `(fmt $MEASURE_PLACES `(what curpt.y)); set CirRad `(fmt $MEASURE_PLACES `(.get-field length: $tmp)); delete curln; return; ); if (c-and (> $NUMPTS 2) (== $arc 0)) then ( set tmp `(what curseg); mvcur -1; set XCenPt `(fmt $MEASURE_PLACES `(what curpt.x)); set YCenPt `(fmt $MEASURE_PLACES `(what curpt.y)); set CirRad `(fmt $MEASURE_PLACES `(.get-field length: $tmp)); mvcur 1; deletept; endnew; return; ); empty_stack; pushcurpt; scr2sheet; if (not pushnearestarc) then ( empty_stack; return; ); model2sheet; set tmp `(.prgeom); if (== `(.index $tmp 0) CIRCLE) then ( set XCenPt `(fmt $MEASURE_PLACES `(.get-field cx: $tmp)); set YCenPt `(fmt $MEASURE_PLACES `(.get-field cy: $tmp)); set CirRad `(fmt $MEASURE_PLACES `(.get-field radius: $tmp)); delete curln; return; ); if (== `(.index $tmp 0) ARC) then ( set XCenPt `(fmt $MEASURE_PLACES `(.get-field cx: $tmp)); set YCenPt `(fmt $MEASURE_PLACES `(.get-field cy: $tmp)); set CirRad `(fmt $MEASURE_PLACES `(.get-field radius: $tmp)); set CTStartAng `(fmt $MEASURE_PLACES `(.get-field start: $tmp)); set CTStopAng `(fmt $MEASURE_PLACES `(.get-field end: $tmp)); delete curln; return; ); ) -- format: doCirTextMac -- Check to make sure we have some text and then call the -- macro doCircleText passing in all the needed variables. macro doCirTextMac ( panel-update $POSTED_PANEL; if (isBufferEmpty CText) then ( echoc No text entered!!\B\n; return; ); .panel-unpost $POSTED_PANEL; doCircleText $XCenPt $YCenPt $CirRad $CTStartAng $CTStopAng $CirTextRotFlg "$CText"; ) -- format: doCircleText -- Main routine that places the circular text on the drawing. macro doCircleText ( locals ang chars i j oldjust oldangle start step stop tmp) ( unsa; set oldjust $TEXT_JUST; set oldangle $TEXT_ANGLE; set chars `(.index `(.string-info "!7") 5); set tmp `(= (!5-!4)); set CTextIA `(= $tmp / `(= ($chars-1))); set TEXT_JUST cc; set TEXT_ANGLE 0; set CirTextRotAng 90; set start 1; set stop $chars; set step 1; if (!6) then ( set CirTextRotAng -90; set start $chars; set stop 1; set step -1; ); set j 0; for i from $start to $stop step $step do ( set j `(= ($j+1)); set CurText `(.get-char "!7" `(= ($j-1))); set ang `(= (!4+($CTextIA*($i-1)))); set CurTextRA `(= ($ang-$CirTextRotAng)); pushpt `(= (!1+(!3*cos($ang)))) `(= (!2+(!3*sin($ang)))); addpt; puttext $CurText; select curtx; if $CTFlattenText then ( flatten -t curtx; ); rotate selected $CurTextRA; ); delete curln; endnew; unsa; set TEXT_JUST $oldjust; set TEXT_ANGLE $oldangle; )