Jump to content
Developer Wiki and Function Reference Links ×

auto numbering symbols


brrt

Recommended Posts

Hello,

I've made a symbol and want to have an autonumbering "id"-field in an attached recordformat. Is this possible to create? Do I have to make a script to make this happen? And what will be the best way of inserting these symbols: place them using the object browser or make a button with a script attached?

greets,

Brrt

[ 09-15-2003, 06:08 AM: Message edited by: brrt ]

Link to comment

I insert the symbol from Browser and then run a script to number the symbols. Here's a simple eg:

Procedure numbernodes;

var

num_nodes:INTEGER;

Procedure number_the_nodes(hob:HANDLE);

Begin

num_nodes:=num_nodes+1;

SetRField(hob,'readings','node number',Num2Str(0,num_nodes));

End;

BEGIN

num_nodes:=0;

ForEachObject(number_the_nodes,C='nodes');

END;

RUN (numbernodes);

The "nodes" are numbered in the order in which they are inserted,starting in the bottom layer,from 1 to whatever. If you need a more complex numbering scheme, you have to figure out the logic for that.

This is how I did it, but you could write a script that would get a total count of instances of the symbol,insert the symbol and then set the record field to count+1, if you preferred. The end result would be the same.

I'm using "class" to find the symbols I'm interested in, but you could also use "name". How you do it is up to you and your needs.

Link to comment
  • 3 weeks later...

there is another script around that allow you to edit a symbol with a data record attached. I got this from the tech board awhile ago. you could do a search to find the original.

Basically you put in your data records name for "my record" and the field you want to nuber for "my field." you can start at any number 1or 100or whatever. It come in handy when I am dooing door or room numbering. I have several iterations for each symbol I might want to use it on.

To use: Double click on the script then click on the symbols in the order you want to number them when youar finished double click in an empty space in your drawing.

-----------------------

Procedure Numberthem;

CONST

kRecName='MyRecord';

kRecField='MyField';

VAR

objhandle:HANDLE;

NumberString:STRING;

Num,x,y:REAL;

BEGIN

Num:=RealDialog('Enter a starting number:','1');

GetPt(x,y);

Objhandle := PickObject(x,y);

while Objhandle <> NIL do

Begin

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