Jump to content
Developer Wiki and Function Reference Links ×

chair numbering?


grant_PD

Recommended Posts

Is there any way to have a symbol that numbers itself as you place instances in the layer? ie. I place 4 chairs in the layer, the instances number themselves 1,2,3,4 on the 2d portion. I place 4 more, they number themselves 5,6,7,8. Take away two and they reassign themselves. Sounds complicated as I write it....

Link to comment
Guest Mark Flamer

If you use a tool based PIO, it can number the objects as they are placed. Having them renumber themselves is much more complicated, but can be done. Look for info on "ResetObject" at the developer website. It has a pretty good article on linking objects.

Link to comment

If you want to use symbols:

To place them could this be a way:

The name of the symbol in this example is Chair.

There's a record with the name RName and a field FName in the drawing.

A text object in the symbol is linked to that record field.

PROCEDURE Voorbeeld;
{This is a menu commando or a document script}
{This is just a sketch, not fully tested}
VAR
crit : STRING;
aant,tel : INTEGER;
x,y : REAL;
b : BOOLEAN;
BEGIN
{count the number of already placed chairs on this layer}
crit:=ConCat(Chr(40),Chr(40),'S=',Chr(39),'Chair',Chr(39),Chr(41),Chr(38),Chr(40),'L=',Chr(39),GetLName(ActLayer),Chr(39),Chr(41),Chr(41));
aant:=Count(crit);
{start a loop until the user selects a tool or presses esc}
REPEAT
{let the user click and place there the symbol}
	GetPt(x,y);
	Symbol('Chair',x,y,0);
{set the number}
	tel:=tel+1;
	SetRField(LNewObj,'RName','FName',Num2StrF(aant+tel));
{redraw the screen to show the symbol}
	Redraw;
UNTIL(b);
END;
RUN(Voorbeeld);

A script can not be run when you delete an object, so you still have to run it manually every time you delete a chair.

How do you want them to be renumbered? The first placed will always have nr1, the second nr2,... and the last placed nrX? If so, it isn't that hard because you can use the order that VS uses. When VS does a search through the objects, it starts with the first created and ends with the last created.

PROCEDURE ReNumber;
{This is a menu commando or a document script}
{This is just a sketch, not fully tested}
VAR
crit : STRING;
tel : INTEGER;


PROCEDURE SetNumber(h : HANDLE);
BEGIN
	tel:=tel+1;
	SetRField(h,'RName','FName',Num2StrF(tel));
END;

BEGIN
crit:=ConCat(Chr(40),Chr(40),'S=',Chr(39),'Chair',Chr(39),Chr(41),Chr(38),Chr(40),'L=',Chr(39),GetLName(ActLayer),Chr(39),Chr(41),Chr(41));
ForEachObject(SetNumber,crit);
Redraw;
END;
RUN(ReNumber);

If you want an other way to renumber them, you'll have to figure out how you want to do them so we can see if it's possible in VS.

Edited by maarten.
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...