FMA Posted March 15 Share Posted March 15 I want to do something that I thought was rather simple but I can't get it to work. I have a symbol called SYMBOLSC which I obtain the handle of: SymbolHandle := GetObject('SYMBOLSC');# Then I place it. Symbol('SYMBOLSC', 0, 0, 0); Now I want to edit its properties. SetAngle(SymbolHandle, angle); I am not quite sure what the SymbolHandle refers to, the last inserted instance of the Symbol or all instances of the Symbols? At any rate I can place the symbol but I am not able to get the SetAngle() part of the code to work, same is true for SetWidth() etc. DelObject(SymbolHandle); is working though which makes me think that there is a problem with editing symbols in general. Would anyone be able to help me with that? Quote Link to comment
michaelk Posted March 15 Share Posted March 15 If you are trying to rotate a symbol already in the drawing: GetSymLoc(SymbolHandle, xLoc, yLoc); HRotate(SymbolHandle, xLoc, yLoc, RealNumberHere ); Quote Link to comment
michaelk Posted March 15 Share Posted March 15 Wait. Just reread your post. You want to set an absolute angle, not a rotation from the existing angle? Quote Link to comment
FMA Posted March 15 Author Share Posted March 15 Thank you for your reply! What I exactly do to the symbol doesn't really matter yet since I am still trying to figure out how to edit it at all. I've tried now: PROCEDURE SYMBOLROTATE; VAR SymbolHandle: HANDLE; xLoc, yLoc: REAL; BEGIN Symbol('SYMBOLSC', 0, 0, 0); SymbolHandle := GetObject('SYMBOLSC'); GetSymLoc(SymbolHandle, xLoc, yLoc); HRotate(SymbolHandle, xLoc, yLoc, 100 ); Message(SymbolHandle, 'coord: ',xLoc, yLoc); {just to test it} ReDrawAll; END; RUN(SYMBOLROTATE); This doesn't do anything except inserting the symbol. I am not sure what the handle exactly refers to and how to edit the symbol once I inserted it. (I know I can rotate the symbol when I insert it, but I would like to know how to edit symbols in vectorscript in general.) Quote Link to comment
michaelk Posted March 15 Share Posted March 15 I'm not the most qualified on this forum to answer VS questions - but… I usually use something like SymbolHandle := LNewObj; LNewObj returns a handle for the last object created by the currently executing script. That way there's no confusion if you have a handle to a symbol instance or a symbol definition. 1 Quote Link to comment
Pat Stanford Posted March 15 Share Posted March 15 11 minutes ago, FMA said: SymbolHandle := GetObject('SYMBOLSC'); Is going to get you a handle to the symbol definition, not the symbol instance places in the drawing. Use Michael's suggestion of 5 minutes ago, michaelk said: SymbolHandle := LNewObj; Quote Link to comment
FMA Posted March 15 Author Share Posted March 15 LNewObj works as a handle, Thank You! I would like to scale the inserted symbol by a certain factor now. None of the commands I tried like HScale2D or SetWidth appear to work. Is the a set of property changing commands that work on symbols? Quote Link to comment
Sam Jones Posted March 15 Share Posted March 15 I use HScale2D all the time on symbol instances, and it works just fine. Quote Link to comment
FMA Posted March 15 Author Share Posted March 15 Then I must be making a mistake. PROCEDURE SYMBOLSCALE; VAR SymbolHandle: HANDLE; xLoc, yLoc: REAL; scaleX, scaleY: REAL; BEGIN Symbol('SYMBOLSC', 0, 10, 0); SymbolHandle := LNewObj; scaleX:= 1.5; scaleY:= 3; GetSymLoc(SymbolHandle, xLoc, yLoc); HScale2D(SymbolHandle, xLoc, yLoc, scaleX, scaleY, TRUE); Message(SymbolHandle, 'coord: ',xLoc, yLoc); {just to test it} ReDrawAll; END; RUN(SYMBOLSCALE); It pasts the object but doesn't scale it. Quote Link to comment
Sam Jones Posted March 15 Share Posted March 15 @FMA You didn't get it wrong. I did. I use the following to scale a symbol instance ObjArray Symbol(SymHdl, Sx, Sy, SAngle); SetObjectVariableInt(LNewObj, 101, 2); { ScaleMode: 1=None, 2=Symmetric, 3=Asymmetric } SetObjectVariableReal(LNewObj, 102, ScaleFactor); 1 Quote Link to comment
FMA Posted March 16 Author Share Posted March 16 I don't know what the 101 and 102 stand for but it works. Thank you very much! Quote Link to comment
michaelk Posted March 16 Share Posted March 16 This is one of the things that seems random when learning vectorscript. Some things are controlled with functions and some are controlled with ObjectVariable - Boolean/Handle/Int/LongInt/Point/Real/String If you can't find it, just keep asking 🙂 Quote Link to comment
FMA Posted March 16 Author Share Posted March 16 Good to know! Thank you for the information. Quote Link to comment
Sam Jones Posted March 16 Share Posted March 16 21 hours ago, FMA said: LNewObj works as a handle, Thank You! An important thing to know about "LNewObj" is that it does not work as a handle; it is a function that returns (gets) a handle to the last created object. It's value will change as soon as anything is created by the script. If you are going to need a handle to a symbol for a variety of reasons, it is best to assign it to a variable and use the variable in all the different places you need it. VAR SymbolName : STRING; SymbolHandle : HANDLE; X, Y, Rot : REAL; X1, Y1, X2, Y2 : REAL; BEGIN Symbol(SymbolName, X, Y, Rot); SymbolHandle := LNewObj; GetBBox(SymbolHandle, X1, Y1, X2, Y2); Rect(X1, Y1, X2, Y2); END; 1 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.