Jump to content

Has anyone got a simple numbering script


Recommended Posts

Jeff,Set the constant MyRecord and MyField to match the record and field your wanting to number, select your objects to number and this should do the trick. tongue.gif" border="0

Dave--------------Procedure Numberthem;CONSTkRecName='MyRecord';kRecField='MyField';

VARobjhandle:HANDLE;NumberString:STRING;Num:REAL;

BEGINNum:=1;

objhandle :=FSActLayer;

WHILE Objhandle <> NIL DO BEGINSetRecord ( Objhandle , kRecName );NumberString:=Num2Str(0 , Num); SetRField ( Objhandle , kRecName , kRecField , NumberString );Num:=Num+1;Objhandle := NextSObj ( Objhandle );END;

END;Run (Numberthem);

[ 05-30-2002: Message edited by: Fuge ]

Link to comment

Funny you asked that. The command FSActLayer is for "first selected object on the active layer" So objects should be numbered in the order they are selected, However FSActLayer doesn't seem to be working correctly in VW9.5.1 mac. No matter the order you select the objects everything is numbered in the order they were created. Same goes forusing FSObject(); A couple for the bug list I believe.

Dave

Link to comment
  • Vectorworks, Inc Employee

FSActLayer returns the "first selected object on the active layer", but not necessarly the first item that you selected. Selection is a binary state, either an item is selected or not, you canot tell how the objects were selected. ie, what would the order be is the objects were part of a marque selestion? In order for a numbering script to work you need to make a tool that numbers as you click on the object.

To get you started you want to use GetPt(x,y) to get the mouse location when you click then use PickObject(x,y) to get the handle to the object or GetPickObjectInfo if the objects might be in a wall.

Here is what the main part of the script should look like.

GetPt(x,y);ObjHand := PickObject(x,y);while Objhandle <> NIL doBeginSetRecord ( Objhandle , kRecName );NumberString:=Num2Str(0 , Num); SetRField ( Objhandle , kRecName , kRecField , NumberString );Num:=Num+1;GetPt(x,y);ObjHand := PickObject(x,y);End;

[ 05-31-2002: Message edited by: klinzey ]

Link to comment

Thanks for the clarification Kev. The description for FSActlayer fooled two of us.

Also heres the complete revised script.---------------------------------------------Procedure Numberthem;CONSTkRecName='MyRecord';kRecField='MyField';

VARobjhandle:HANDLE;NumberString:STRING;Num,x,y:REAL;

BEGINNum:=1;GetPt(x,y);Objhandle := PickObject(x,y);while Objhandle <> NIL doBeginSetRecord ( Objhandle , kRecName );NumberString:=Num2Str(0 , Num); SetRField ( Objhandle , kRecName , kRecField , NumberString );Num:=Num+1;GetPt(x,y);Objhandle := PickObject(x,y);End;

END;Run (Numberthem);

Link to comment

Try ThisDave-------------------------Procedure Numberthem;CONSTkRecName='MyRecord';kRecField='MyField';

VARobjhandle:HANDLE;NumberString:STRING;Num,x,y:REAL;

BEGINNum:=RealDialog('Enter a starting number:','1');GetPt(x,y);Objhandle := PickObject(x,y);while Objhandle <> NIL doBeginSetRecord ( Objhandle , kRecName );NumberString:=Num2Str(0 , Num); SetRField ( Objhandle , kRecName , kRecField , NumberString );Num:=Num+1;GetPt(x,y);Objhandle := PickObject(x,y);End;

END;Run (Numberthem);

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