grimster Posted June 1, 2005 Share Posted June 1, 2005 Help! I am trying to create a symbol that inlcludes a text box which will automatically reference the X and Y coordinates from the OIP. I can't write Vector Scripts. Is this the only way of doing this and if so, has anyone written one I could use? More generally, what is the best way to go about teaching myself Vector Script. Reading through these postings it seems like the thing to do! Thanks Grimster Quote Link to comment
Rick Francken Posted June 1, 2005 Share Posted June 1, 2005 Do you want to reference the X and Y coordinates of the currently selected object? Or one specific object? Elaborate a bit more on what you want it to do. Quote Link to comment
Alexandre Villares Posted June 2, 2005 Share Posted June 2, 2005 Hi, A VectorScript recipe for you... - Go to Organise > Scripts > Create Plug-in... - Press 'New...', give it a name, choose 'Point Object' and press 'OK'. - Press 'Proprieties' and check 'Reset on Move' and 'Reset on Rotate'. - Now press 'Script...' and paste this: code: PROCEDURE XYText; VAR objectHand, recordHand, wallHand : HANDLE; objectName : STRING; X, Y : REAL; BEGIN IF GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand) THEN BEGIN {Get Object info} SetObjectVariableBoolean (objectHand,800,TRUE); {Let the text style be changed by the user from outside} GetSymLoc(objectHand, X, Y); {Get Object Position} END; Lous(0,0); {Something to see, won't print} TextOrigin (0,0); {Set text position, note the object internal coordinate system)} FillPat(0); {Set Fill to None} BeginText; Concat('(',Num2StrF(X),')(',Num2StrF(Y),')' ) {Note there is no ; at the end of this line} EndText; END; RUN (XYText);[/code] Then you have to add it to your workspace (File > Workspace Editor), choose 'Edit a copy' and at the 'Tool' tab you'll find it under the 'Miscellaneus' category. [ 06-07-2005, 10:01 AM: Message edited by: Alexandre B A Villares ] Quote Link to comment
islandmon Posted June 16, 2005 Share Posted June 16, 2005 master Alexandre please assist me: How does one update the 'REAL' XY in text to reflect the actual coordinates of XY? Although the symbol & text are placed properly, createText defaults to the page center origin 0,0 not the true setorigin. _____________________ PROCEDURE BenchmarkTXT; VAR h : HANDLE; X, Y : REAL; BEGIN CallTool(-221); h := FSActlayer; GetLocPt(h,X,Y); TextOrigin(X+.01, Y+.01); CreateText(Concat('E:', X, '? N:', Y)); Symbol('Benchmark',X,Y,0); DSelectAll; END; RUN(BenchMarkTXT); ___________ thanx in advance eja Quote Link to comment
ccroft Posted June 17, 2005 Share Posted June 17, 2005 EJ Your script works as it should on my system. Not sure why...some preference setting perhaps? BTW...have a look at MouseDown. Unless you have some other need of these loci, it would replace CallTool,FSAct and GetLoc. Later Charles Quote Link to comment
islandmon Posted June 17, 2005 Share Posted June 17, 2005 Thanx to All ... Here's the update: ________________________________ PROCEDURE BenchmarkTXT; VAR h : HANDLE; X, Y : REAL; n, i : INTEGER; objectHand, recordHand, wallHand : HANDLE; objectName : STRING; BEGIN h := FSActLayer; REPEAT UNTIL MouseDown(X,Y); IF GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand) THEN BEGIN {Get Object info} SetObjectVariableBoolean (objectHand,800,TRUE); {Let the text style be changed by the user from outside} GetSymLoc(objectHand, X, Y); {Get Object Position} END; TextOrigin(X, Y); {Set text position, note the object internal coordinate system)} FillPat(1); {Set Fill} Createtext(Concat(' # ['' E:', Num2StrF(X), '?''N:', Num2StrF(Y),']')); Symbol('Benchmark',X,Y,0); DSelectAll; END; RUN(BenchMarkTXT); Quote Link to comment
Alexandre Villares Posted July 7, 2005 Share Posted July 7, 2005 Hi islandmon, I think I don't understand exactly what you want to do. My example should work as a plug-in object, it shouldn't use MouseDown, and it should be set to regenerate (redraw) when moved, so retrieving it's own new position. The text inside de object should be set using it's internal coordinate system, that is 0,0 like my earlier exemple. I didn't run your code yet but I think you must be running it as a tool. That's a very different approach. To run as a tool, you should not use the GetCustomObjectInfo and would draw free standing text objects using the drawing coordinates, perhaps on the MouseDown position... [ 09-08-2005, 01:25 PM: Message edited by: Alexandre B A Villares ] Quote Link to comment
vworker Posted July 27, 2005 Share Posted July 27, 2005 i am using the above script but am having two problems 1. the x,y values are not the user origin set values, it looks like it is use absalut x,y value. how can i change it to get the x,y based on the user origin. 2. can i create a togle in the object info pallet that changes the script to either get the x value OR the y value your help is really appreciated Quote Link to comment
mattb_ Posted October 11, 2005 Share Posted October 11, 2005 I'm having a similar problem. How do I get the location of a group centre? I need to convert a group to a symbol, but can't get the group location in xy.....help? Quote Link to comment
MullinRJ Posted October 11, 2005 Share Posted October 11, 2005 If you have a handle to the Group object, use hCenter(grpHand, X, Y); Quote Link to comment
mattb_ Posted October 12, 2005 Share Posted October 12, 2005 that worked quite well. Though now I have a new problem.... I select a bunch of objects, then run through them with a while statement. h := FSActLayer; while h <> NIL do begin hCenter(h,x,y); symbol(sym,x,y); DelObject(h) h := NextObj(h); end; this code will endlessly execute. Creating thousands of symbols. Because each time a symbol is created it is added to h and thus continues to execute.....Any ideas on how to stop this? [ 10-12-2005, 01:37 AM: Message edited by: mattb_ ] Quote Link to comment
Rick Francken Posted October 12, 2005 Share Posted October 12, 2005 mattb, just a guess...in your loop you are creating a new object each time with the "Symbol(sym,x,y)" call, meaning that you just added another object to the list. So your code will continue to find a NextObj. If you are only iterating over selected objects, deselect the newly created symbol reference, I think it's "SetDSelect(LNewObj)" or something like that. If that doesn't fix the problem, you may have to structure the loop differently, maybe start with the last object and work backward with "PrevObj", or use a "For i:= 1 to ObjectCount do" Hope this steers you in the right direction. -Rick Francken Quote Link to comment
Yotarou Posted October 12, 2005 Share Posted October 12, 2005 mattb, It's good in this? code: { code-1 } Locus(0, 0); hLoc:= LNewObj; h := FSActLayer; while h <> hLoc do begin hCenter(h,x,y); symbol(sym,x,y); hNext:= NextSObj(h);{not NextObj} DelObject(h); h := hNext; end; DelObject(hLoc); { code-2: The symbol is inserted in each original order. } h := FSActLayer; while h <> NIL do begin hCenter(h,x,y); symbol(sym,x,y); hSym:= LNewObj; HMoveBackward(hSym, TRUE); { The symbol is moved to the background of object(h). It's possible to omit this. } hNext:= NextObj(hSym); while hNext <> h do begin HMoveForward(hSym, FALSE); hNext:= NextObj(hSym); end; { } hNext:= NextSObj(h); DelObject(h); h := hNext; end; [/code] I'm not confirming this code's execution. 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.