Jump to content
Developer Wiki and Function Reference Links ×

Editing Symbols in Vectorscript


Recommended Posts

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?

 

   

Link to comment

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.)
 

Link to comment

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.

  • Like 1
Link to comment
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;

 

Link to comment

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?

Link to comment

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.

Link to comment

@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);

 

  • Like 1
Link to comment

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 🙂 

Link to comment
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;

 

  • Like 1
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...