Jump to content
Developer Wiki and Function Reference Links ×

Spooky Problem with self-made space tool...


Recommended Posts

Hello,

I programmed a custom made "space" tool. It's a 2D path object.

It's a room stamp and it retrieves the area (and perimeter) of the 2D path and writes it into a database. The space tool then places a room stamp symbol that is linked to the database.

The strange thing is:

If I use the space tool in the view area of a sheet layer everything is ok first.

But if I move the view area on the sheet all the placed room stamps disappear.

I can make them reappear by selecting and editing the polyline.

Is there a bug in my script or is it a VW problem?

Can anybody help?

Thank you

kind regards

VvierA

Script (you need a database called "db_raumdaten" and the fields "raumflaeche" and "raumumfang". You also need a symbol that is linked to the database fields and the symbol needs to be selected as a parameter of the PIO)

PROCEDURE dballesstempel;

CONST

kObjXPropSpecialEdit = 3; {das erste Konstantenpaket dient dem 'event enabler' gem. http://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=176863#Post176863}

kReshapeSpecialEdit = 3;

kObjXIs2DSurfaceEligible = 14;

kObjXPropEditGroup = 1;

kObjXPropEditGroupPath = 2;

kObjOnInitXProperties = 5;

kResetEventID = 3;

feldSTRflaeche = 'raumflaeche';

feldSTRumfang = 'raumumfang';

datenbankSTR = 'db_raumdaten';

VAR

theEvent, theButton :LONGINT;

status :BOOLEAN;

result :BOOLEAN;

polyHand, objHand, recHand, wallHand, pathHand, dupeHand, symbHand, layerhandle :HANDLE;

objName, symName, flaecheSTR, umfangSTR, par_raumbezeichnung, recordname, pioclass, flaeche_korrigSTR, rundungSTR :STRING;

flaeche, umfang, flaeche_korrig, flaeche_korrekt, p1X,p1Y,p2X,p2Y,symbscale, layerscale: REAL;

stempelpos :VECTOR;

BEGIN

vsoGetEventInfo(theEvent, theButton);

CASE theEvent OF

kObjOnInitXProperties:

BEGIN

status:=SetObjPropCharVS(kObjXPropSpecialEdit,Chr(kReshapeSpecialEdit));

status:=SetObjPropVS(kObjXIs2DSurfaceEligible,TRUE);

status:=SetObjPropCharVS(kObjXPropEditGroup,Chr(kObjXPropEditGroupPath));

status:=vsoInsertAllParams;

END;

kResetEventID:

{Hier beginnt der eigentlich Code f?r das Duplizieren des Polygons und das Einf?gen des Raumstempelsymbols}

BEGIN

IF GetCustomObjectInfo(objName, objHand, recHand, wallHand) THEN

BEGIN

pathHand := GetCustomObjectPath(objHand);

pioclass := GetClass(objHand);

dupeHand := CreateDuplicateObject(pathHand, objHand);

SetClass(dupeHand,pioclass);

SetPolyClosed(dupeHand, TRUE);

stempelpos := GetPtInPoly(dupeHand); {Schwerpunkt des Polygons finden und in Vector speichern}

flaeche := ObjAreaN(dupeHand); {Feststellung der Fl?che}

flaeche_korrig := ppar_flaeche_korrig; {?bernahme des Korrekturwunschs aus den Parametern}

flaeche_korrekt := flaeche+flaeche_korrig;

umfang := HPerimN(dupeHand); {Feststellung des Umfangs}

flaeche_korrigSTR := Num2Str(2,flaeche_korrig); {Korrekturfl?che wird in String umgewandelt, damit sie in die Datenbank gepatcht werden kann}

flaecheSTR := Num2Str(-2,flaeche_korrekt);

umfangSTR := Num2Str(2,umfang); {verwandelt Zahl in String - eine Voraussetzung zur Eintragung in die Datenbank}

{Message('Fl?che ', flaeche, 'Fl?cheSTR', flaecheSTR);} {Kontrollausgabe der Fl?chen}

symName :=ppar_symb; {?bernahme des Symbolnamens aus den Parametern}

{symbol(symName, stempelpos.x, stempelpos.y,0);}

IF ((pControlPoint01X=0) AND (pControlPoint01Y=0)) THEN {Ein manuelles Setzen der Kontrollpunkte auf 0 soll ein Reset der Position des Raumstempels in die Polygonmitte zur Folge haben}

BEGIN

{resultstatus := GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand);}

symbol(symName, stempelpos.x, stempelpos.y,ppar_dreh);

symbHand := LNewObj;

{HScale2D(symbHand, pControlPoint01X, pControlPoint01Y, ppar_scale, ppar_scale, TRUE);}

recordname := GetName(recHand);

SetRField(objHand,recordname,'ControlPoint01X',Num2Str(9,stempelpos.x));

SetRField(objHand,recordname,'ControlPoint01Y',Num2Str(9,stempelpos.y));

{Message('Objekthandle ',objHand,'recordname ',recordname,' Kontrollpunkt ', pControlPoint01X,' ', pControlPoint01Y,' ',stempelpos.x,' ',stempelpos.y);} {Kontrollausgabe der Symbolbreite}

END

ELSE BEGIN

symbol(symName, pControlPoint01X, pControlPoint01Y,ppar_dreh);

{symbHand := LNewObj;}

{HScale2D(symbHand, pControlPoint01X, pControlPoint01Y, ppar_scale, ppar_scale, TRUE);}

{SetSelect(LNewObj);}

{Scale(ppar_scale,ppar_scale);}

END;

symbHand := LNewObj;

layerHandle := ActLayer; {Handle f?r aktiven Layer abfragen}

layerScale := GetLScale( layerHandle ); {Layer Scale abfragen}

SetObjectVariableInt(symbHand,101,2); {Symbol auf symmetrische Skalierung setzen}

symbscale := (ppar_scale*layerScale); {Ma?stab des Layers mit manueller Skalierung multiplizieren}

SetObjectVariableReal(symbHand,102,symbscale);

SetObjectVariableReal(symbHand,103,symbscale);

{Message('Objekthandle ',symbHand,'symbscale ',symbscale);}

{SetSelect(LNewObj);}

{Scale(ppar_scale,ppar_scale);}

{ScaleObjectN(symbHand,0,0,1,1);} {Symbol skalieren}

{GetBBox(symbHand,p1X,p1Y,p2X,p2Y);} {Bounding Box des Symbols ermitteln}

{Message('Koordinaten ', p1X,' ',p1Y,' ',p2X,' ',p2Y)}; {Kontrollausgabe der Symbolbreite}

SetRField(symbHand, datenbankStr, feldSTRflaeche, flaecheSTR);

SetRField(symbHand, datenbankStr, feldSTRumfang, umfangSTR);

SetRField(symbHand, datenbankStr, 'raumnummer', ppar_raumnummer);

SetRField(symbHand, datenbankStr, 'raumbezeichnung', ppar_raumbezeichnung);

SetRField(symbHand, datenbankStr, 'bodenbelag', ppar_bodenbelag);

SetRField(symbHand, datenbankStr, 'ukrd', ppar_ukrd);

SetRField(symbHand, datenbankStr, 'ukfd', ppar_ukfd);

SetRField(symbHand, datenbankStr, 'okffb', ppar_okffb);

SetRField(symbHand, datenbankStr, 'okrfb', ppar_okrfb);

SetRField(symbHand, datenbankStr, 'raumkategorie', ppar_raumkategorie);

SetRField(symbHand, datenbankStr, 'raum_ehem', ppar_raum_ehem);

SetRField(symbHand, datenbankStr, 'neu_bestand_umbau', ppar_modi);

SetRField(symbHand, datenbankStr, 'flaeche_korrektur', flaeche_korrigSTR);

END;

END;

END;

END;

Run(dballesstempel);

Link to comment

Maybe I found a hint how to solve the problem.

It seems to me, that recalculating the PIO makes the room stamp reappear.

It's a workaround to invoke the recalculation by editing the polyline of the PIO or editing a parameter. But that's annoying.

I checked the options "Recalculate by event, by movement and by rotation" in the PIO options dialog but VW does not recognize the movement of the view area as a movement that invokes the recalculation.

Is there a script to force all placed PIOs to recalculate. So I don't have to do it manually?

Link to comment

Thank you very much.

Although I made the script earlier (with lots of help from you) I am still a beginner and do not know how to create an event loop or call the ResetObject function.

Do you know some sort of sample or reference code so maybe I can adapt it for my purposes? That would be really great.

But anyway - thank you very much for your help so far.

VvierA

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