Jump to content

Hippocode

Member
  • Posts

    796
  • Joined

  • Last visited

Posts posted by Hippocode

  1. While building my code, the object started behaving weird.

    Its a 2dpath object with text in it, the text gets duplicated outside the object, on a different coordinate?

    BEGIN
    { retrieve plug-in object information }
    result:= GetCustomObjectInfo(objName,objHd,objrecHd,wHd);
    
    vsoGetEventInfo(theEvent, theButton);
    CASE theEvent OF
    	5:{kObjOnInitXProperties:}
    	BEGIN
    		status:= SetObjPropVS(18, TRUE); {kObjXPropAcceptStates}
         			status:= SetObjPropVS(8, TRUE); {kObjXPropHasUIOverride}
    		status:= SetObjPropCharVS(kObjXPropSpecialEdit,Chr(kReshapeSpecialEdit));
    		status:= SetObjPropVS(kObjXIs2DSurfaceEligible,TRUE);
    		status:= SetObjPropCharVS(kObjXPropEditGroup,Chr(kObjXPropEditGroupPath));
    		status:= SetObjPropCharVS(11, Chr(1));
                  		status:= SetObjPropCharVS(11, Chr(2));
    		status:= vsoInsertAllParams;
    	END;
    	3: {kParametricRecalculate}
    	BEGIN
    		IF vsoStateGetParamChng( objHd, widgID, prmIndex, oldValue ) THEN BEGIN
    			{oldName     := Num2Str(0,PPARAM2);}
    
    
    			{SetParameterVisibility(objHd,'param1',TRUE);}
    
    		END;
    		vsoStateClear(objHd);
    	END;
    		41: {kObjOnWidgetPrep}
     		BEGIN
      			vsoWidgetSetVisible( 1, TRUE ); 
      			vsoSetEventResult( -8 {kObjectEventHandled} );
    		END;
    
    END;
    
    { if the plug-in object info was successfully retrieved }
    IF result THEN BEGIN
                   {2d shape}
    	Main;
    END;
    END;

  2. I'm trying to understand the whole event part of a PIO.

    Is it possible to change the visibility of a widget in a PIO, depending on the choice or change of one of the widgets ?

    Lets say param 1 changes, widget param2 should be hidden.

    I tried to change the visibility in kParametricRecalculate, but it seems that ain't possible.

    PROCEDURE Sample;
    VAR
    objectName  		: STRING;
    objectHand  			: HANDLE;
    recordHand  			: HANDLE;
    wallHand    			: HANDLE;
    theEvent, message		: LONGINT;
    result				: BOOLEAN;
    x, y, z	, diffAng		: REAL;
    is3D, scaleText		: BOOLEAN;
    widgID, changeID		: LONGINT;
    grpType			: LONGINT;
    prmIndex			: INTEGER;
    oldValue			: STRING;
    oldScale, newScale	: REAL;
            oldName, newName     : STRING;
    
    BEGIN
    
    result := GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand);
    vsoGetEventInfo(theEvent, message );
    
    CASE theEvent OF
    	5: {kObjOnInitXProperties}
    	BEGIN
         			result:= SetObjPropVS(8, TRUE); {kObjXPropHasUIOverride}
        			result:= SetObjPropVS(12, TRUE); {kObjXHasCustomWidgetVisibilities}
    		SetPrefInt( 590, 1 ); {varParametricEnableStateEventing, kParametricStateEvent_ResetStatesEvent}
    		result := SetObjPropVS(18, TRUE); {kObjXPropAcceptStates}
    		result:= vsoInsertAllParams;
    
    	END;
    	44: {kObjOnAddState}
    	BEGIN
    		message := vsoStateAddCurrent( objectHand, message );
    	END;
    	3: {kParametricRecalculate}
    	BEGIN
    		Rect( 0mm, 0mm, 20mm, -10mm );
    
    		IF vsoStateGetParamChng( objectHand, widgID, prmIndex, oldValue ) THEN BEGIN
    			MoveTo( 0,-30mm );
    			CreateText( Concat( 'Object parameter just changed! widgetID=', widgID, ' paramIndex=', prmIndex,' OldValue=', oldValue ) );
    
    			vsoWidgetSetVisible( 2, FALSE );
    
    		END;
    		vsoStateClear( objectHand );
    	END;
    		 41: {kObjOnWidgetPrep}
     		BEGIN
      			vsoWidgetSetVisible( 1, TRUE ); 
      			vsoWidgetSetVisible( 2, TRUE ); 
      			vsoWidgetSetVisible( 3, TRUE ); 
    
      			vsoSetEventResult( -8 {kObjectEventHandled} );
    		 END;
    END;
    END;
    RUN( Sample );

  3. Yup that worked, also had to play with the insertionpoints to get the duplicates on the right spot.

    PROCEDURE intersect;
    VAR
    h1, h2, h3, h4 :HANDLE;
    pt :VECTOR;
    P1,P2,P3,P4 :POINT;
    BEGIN
    WHILE h1 = NIL DO BEGIN
    	Message('Pick the first object...');
    	GetPt(pt.x, pt.y);
    	h1 := PickObject(pt.x, pt.y);
    	GetSymLoc(h1,P1.x,P1.y);
    	h1 := CreateDuplicateObject(GetCustomObjectPath(h1),NIL);
    	GetSymLoc(h1,P3.x,P3.y);
    END;
    WHILE h2 = NIL DO BEGIN
    	Message('Pick the second object...');
    	GetPt(pt.x, pt.y);
    	h2 := PickObject(pt.x, pt.y);
    	GetSymLoc(h2,P2.x,P2.y);
    	h2 := CreateDuplicateObject(GetCustomObjectPath(h2),NIL);
    	GetSymLoc(h2,P4.x,P4.y);
    END; 
    	{ close the copy }
    	SetPolyClosed(h1, True);
    	SetPolyClosed(h2, True);
    
    { move them to the right spot  }
    HMove(h1,P3.x+P1.x,P3.y+P1.y);
    HMove(h2,P4.x+P2.x,P4.y+P2.y);
    
    h4 := IntersectSurface(h1, h2);
    
    SetFPat(h4, 3);
    ClrMessage;
    END;
    RUN(intersect);

  4. Trying to get a handle to the overlap of path based objects.

    In particularly, the space object.

    The code does work on a simple rectangle but doesn't on a space object.

    Thus I added the GetCustomObjectPath hoping that would fix it.

    Any suggestions ?

    PROCEDURE intersect;
    VAR
    h1, h2, h3, h4 :HANDLE;
    pt :VECTOR;
    BEGIN
    WHILE h1 = NIL DO BEGIN
    	Message('Pick the first object...');
    	GetPt(pt.x, pt.y);
    	h1 := PickObject(pt.x, pt.y);
    	h1 := GetCustomObjectPath(h1);
    END;
    WHILE h2 = NIL DO BEGIN
    	Message('Pick the second object...');
    	GetPt(pt.x, pt.y);
    	h2 := PickObject(pt.x, pt.y);
    	h2 := GetCustomObjectPath(h2);
    END; 
    
    
    h4 := IntersectSurface(h1, h2); { tried this, nothing }
    {h4 := AddSurface(h1, h2);  tried this too, also nothing }
    
    
    SetFPat(h4, 3);
    ClrMessage;
    END;
    RUN(intersect);

  5. What I'm trying to achieve is a custom PIO that can be compared with the HVAC Straight Duct.

    Different from the Straight Duct is that I want it to be a polylone, so I can draw my ventilation way faster, including the corners.

    My idea was, to offset user defined path (2d path object) once left and once right.

    Then i'd try to add all the vertexes of the right new path to the left new path, so I can create a closed polygon wrapped around the user defined path.

    For some reason, I can only get the coordinates/vertices of the left OR the right offset, not both of them.

    Trying to add vertexes to the other fails horribly :(

    Any ideas ?

    		{ obtain a handle to the path polygon of the object }
    	pathHd:= GetCustomObjectPath(objHd);
    
    	{ get the number of vertices in the path }
    	num_vertices:= GetVertNum(pathHd);
    
    	{ draw the piping lines and text label }
    	FOR i:= 1 TO num_vertices DO BEGIN
    		GetPolylineVertex(pathHd, i, x, y, vertexType, vertexRadius);
    		SetPolylineVertex(pathHd, i, x, y, 3, Afronding, TRUE);
    	END;
    	SetPolyClosed(pathHd, False);
    
    	dupeHand := CreateDuplicateObject(pathHd, objHd);
    
    
      		LeftOffsetHd:= OffsetPoly(dupeHand, 10, 1, False, False, 16, 1);
      		RightOffsetHd:= OffsetPoly(dupeHand, -10, 1, False, False, 16, 1);
    	FOR i:= 1 TO num_vertices DO BEGIN
    		GetPolylineVertex(LeftOffsetHd, i, x, y, vertexType, vertexRadius);
    		InsertVertex(RightOffsetHd,x,y,1,vertexType,vertexRadius);
    {Here I assume that because I add a vertex before the first one, this new vertex will be "number one"}
    	END;

  6. AlrtDialog(concat(((GetPrefReal(57)/GetLScale(GetLayer(oh))) * 72) / 25.4)); 

    Try this to get the fontsize if needed, it should work.

    source: GetTextSize

    SetObjectVariableBoolean(oh,800,TRUE); 

    worked great but it also changes the dimensions :(

  7. I've been trying to "round" or lets say "fillet" a custom polyline PIO.

    It works with ArcTo when using some simple vectorscript like this:

    BeginPoly;
    ArcTo(0,50,5);
    ArcTo(50,50,5);
    ArcTo(50,-50,5);
    ArcTo(0,-50,5);
    EndPoly;

    I fail at doing so when I try it on a PIO.

    When looping trough the vertexes, I use the same code (ArcTo) to define the next points without result.

    FOR i:= 2 TO num_vertices DO BEGIN
    GetPolyPt(pathHd,i,v2x,v2y);
    GetPolyPt(pathHd,i - 1,v1x,v1y);
    ArcTo(v2x,v2y,5);
    

    I also tried to change the vertexes after they were added as a polyline:

    FOR i := 1 TO num_vertices DO BEGIN
    GetPolylineVertex(polyHd, i, x, y, vertexType, vertexRadius);
    SetPolylineVertex(polyHd, i, x, y, 3, kFilletRadius, TRUE);
    END;

    Does anyone know how to handle this properly ?

  8. Tweak the script as you need it, as it is written for my custom records and space objects, but hey it works here.

    => draw space objects on a layer.

    => Add a record with a field on each symbol you will use, change the record and fieldnames in the script or keep the current ones.

    => add symbols to that layer, or another layer with the same level ( example: object on "niv 0", symbol on "0 symbols", both share 0 as level )

    => Make sure your are in the layer with symbols before running the script.

    => Run the script once, when no error message appears, all symbols will have the spacename in their record

    => Make a worksheet, dbrow that searches for a value in that record field

    => sort+sum on spacename and then on symbol name

    => you have a list of symbols/each room/space

    I would like to thank everyone for helping me out with all my questions, without this forum I probably wouldn't have made it !

    Procedure FindSymbols;
    VAR
    i,j:											INTEGER;
    temp_string,defaultRecName,defaultFieldName:				STRING;
    originPt:										POINT;
    
    ObjectHandle, PolyHandle:DYNARRAY [] OF HANDLE;
    SpaceName: DYNARRAY [] OF STRING;
    SpaceXOrigin,SpaceYOrigin: DYNARRAY [] OF REAL;
    
      	handleArrayCount,ArrayCounter :INTEGER;
      	handleArrayAlloc :INTEGER;
    
    FUNCTION GetSymbols(SymHandle:HANDLE) :BOOLEAN;
    VAR
    	symPt:					POINT;
    	SymbolName,recName:			STRING;
    BEGIN
    	FOR j:=1 TO NumRecords(SymHandle) DO BEGIN
    		recName := GetName(GetRecord(SymHandle, j));
    		IF recName = defaultRecName THEN BEGIN
    			SymbolName:=GetSymName(SymHandle);
    			IF SymbolName <>'' THEN BEGIN
    				GetSymLoc(SymHandle,symPt.x,symPt.y);
    				FOR i:=1 TO handleArrayAlloc DO BEGIN
    					IF PtInPoly(symPt.x-SpaceXOrigin[i],symPt.y-SpaceYOrigin[i],PolyHandle[i]) THEN BEGIN
    						{for testing only: AlrtDialog(concat(SymbolName,' IS FOUND IN ',SpaceName[i],' ON : x=',symPt.x,' y=',symPt.y));}
    
    						{ Store new string }
    						SetRField(SymHandle,recName,defaultFieldName,SpaceName[i]);
    					END;
    				END;
    			END;
    		END;
    	END;
    END;
    
    Procedure GetSpace(ObjHnd:HANDLE);
    BEGIN
    	{ Check for Handle to excist }
    	ObjectHandle[ArrayCounter]:=ObjHnd;
    
    	{ Handle Found, continue }
    	IF ObjectHandle[ArrayCounter] <> NIL THEN BEGIN
    		{ Get space info }
    		SpaceName[ArrayCounter]:=GetRfield(ObjHnd,'TDE_Space','__SpaceName');
    		{ Get the path }
    		PolyHandle[ArrayCounter]:=GetCustomObjectPath(ObjHnd);
    		{ Get the space insertion point to correct the coordinates when comparing }
    		GetSymLoc(ObjHnd,SpaceXOrigin[ArrayCounter], SpaceYOrigin[ArrayCounter]);
    	END;
    	ArrayCounter:=ArrayCounter+1;
    END;
    BEGIN
    { The record/field name of the used symbols }
    defaultRecName:='TDE_00 algemeen';
    defaultFieldName:='Ruimte';
    temp_string:=GetLName(ActLayer);
    
    { only use the space objects on the right constructionlevel }
    IF POS('-1', temp_string)<>0 THEN BEGIN
    	handleArrayAlloc:=COUNT((PON=TDE_Space) & (L='niv -1'));
    END
    ELSE IF POS('0', temp_string)<>0 THEN BEGIN
    	handleArrayAlloc:=COUNT((PON=TDE_Space) & (L='niv 0'));
    END
    ELSE IF POS('+1', temp_string)<>0 THEN BEGIN
    	handleArrayAlloc:=COUNT((PON=TDE_Space) & (L='niv +1'));
    END
    ELSE IF POS('+2', temp_string)<>0 THEN BEGIN
    	handleArrayAlloc:=COUNT((PON=TDE_Space) & (L='niv +2'));
    END
    ELSE IF POS('+3', temp_string)<>0 THEN BEGIN
    	handleArrayAlloc:=COUNT((PON=TDE_Space) & (L='niv +3'));
    END
    ELSE BEGIN
    	handleArrayAlloc:=COUNT((PON=TDE_Space));
    	Message('No level found, ALL spaceobjects will be used');
    END;
    
    IF handleArrayAlloc > 0 THEN BEGIN
    	{ Define arrays }
    	ALLOCATE ObjectHandle [1..handleArrayAlloc];
    	ALLOCATE PolyHandle [1..handleArrayAlloc];
    	ALLOCATE SpaceName [1..handleArrayAlloc];
    	ALLOCATE SpaceXOrigin [1..handleArrayAlloc];
    	ALLOCATE SpaceYOrigin [1..handleArrayAlloc];
    
    	{ Loop trough each custom space object and store handles and general info in arrays }
    	ArrayCounter:=1;
    	IF POS('-1', temp_string)<>0 THEN BEGIN
    		ForEachObject(GetSpace,((PON=TDE_Space) & (L='niv -1')));
    	END
    	ELSE IF POS('0', temp_string)<>0 THEN BEGIN
    		ForEachObject(GetSpace,((PON=TDE_Space) & (L='niv 0')));
    	END
    	ELSE IF POS('+1', temp_string)<>0 THEN BEGIN
    		ForEachObject(GetSpace,((PON=TDE_Space) & (L='niv +1')));
    	END
    	ELSE IF POS('+2', temp_string)<>0 THEN BEGIN
    		ForEachObject(GetSpace,((PON=TDE_Space) & (L='niv +2')));
    	END
    	ELSE IF POS('+3', temp_string)<>0 THEN BEGIN
    		ForEachObject(GetSpace,((PON=TDE_Space) & (L='niv +3')));
    	END
    	ELSE BEGIN
    		ForEachObject(GetSpace,((PON=TDE_Space)));
    	END;
    
    	{ Loop trough all the symbols once, but check their location on each space object }
    	{ Only using the symbols of the current active layer ! }
    	ForEachObjectInLayer(GetSymbols,0,2,0);
    END
    ELSE BEGIN
    	Message('No space objects found   :(');
    END;
    END;
    Run(FindSymbols);

  9. Yeah I finaly get it :)

    This is the working script:

    Procedure FindSymbols;
    VAR
    SpaceHandle,PolyHandle: 	HANDLE;
    i,j:					INTEGER;
    temp_string:				STRING;
    originPt:				POINT;
    Procedure GetSpace(ObjHandle:HANDLE);
    VAR
    	Temp:INTEGER;
    
    FUNCTION GetSymbols(SymHandle:HANDLE) :BOOLEAN;
    VAR
    	symPt:			POINT;
    	SymbolName:		STRING;
    BEGIN
    	GetSymLoc(SymHandle,symPt.x,symPt.y);
    	SymbolName:=GetSymName(SymHandle);
    	IF PtInPoly(symPt.x-originPt.x,symPt.y-originPt.y,PolyHandle) AND (SymbolName <>'') THEN BEGIN
    		AlrtDialog(concat(SymbolName,' IS FOUND IN ',GetName(ObjHandle),' ON : x=',symPt.x,' y=',symPt.y));
    		{ we found the symbol in the spaceobject }
    	END;
    END;
    BEGIN
    	SpaceHandle:=ObjHandle;
    	{ Get the space insertion point to correct the coordinates }
    	GetSymLoc(ObjHandle,originPt.x, originPt.y);
    	{ space found }
    	IF SpaceHandle <> NIL THEN BEGIN
    		{ Get the path }
    		PolyHandle:=GetCustomObjectPath(SpaceHandle);
    
    		{ Only get all the objects in the current layer }
    		ForEachObjectInLayer(GetSymbols,0,2,0);
    	END;
    END;
    BEGIN
    { Loop trough each custom space object }
    ForEachObject(GetSpace,((PON='Space')));
    END;
    Run(FindSymbols);

  10. Well, I tested my assumptions with a rectangle ( see added picture to this post ).

    The weird thing is, that the script gets the path found in the rectangle. The rectangle has the same size as the path, but starts in the middle of the path with its top left boxpoint.

    Wherever I move the symbols within the rectangle, it will get found as if it is in the spaceobject !

    Now my guess is, that If i substract(y) and add(x) half of the space bounding box to each coordinate of the symbol, the script would work. But I'm looking for an explanation why its off :/

    In the space PIO info tab, the point x,y is also placed on -250,250 instead of 0,0 while in the drawing its centerpoint it at 0,0. This is also returned by getsimloc(spaceobject).

    I Guess I found it ;)

  11. Allright,

    Opened a new document, created a speaceobject, placed 2 symbols in it to test my script.

    The script will return a dialog for each symbol it can find within the poly path of the vw space object.

    The weird thing is, it works, but only for symbols placed at the bottom or under the space object.

    I believe that the loaded path gets shifted down for some reason. Enlighten me ?:(

    The file(vw2010) is added to this post, including the script

  12. update:

    I managed to get the relationship between the values.

    If I do the following calculation, the numbers match !

    (Getsymloc/10)+Getorigin= insertionpoint on hover.

    Since a factor 10 is involved I think about units. at this point i'm using cm.

    Changing them to mm gives the following:

    (Getorigin values raise factor 10 it seems)

    Getsymloc+getorigin= insertionpoint.

    Well that sucks. This means that the getsymlocation always returns in mm, while getorigin returns in the units from the settings.

  13. I've tried your suggestion but fail at getting the right insertion point of the point PIO.

    I guess that's the same problem I'm having in the following script: http://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=178052Post178052

    Back to this one:

    GetSymLoc returns me:-137060,-348297.79

    GetOrigin returns me:-955,1003

    hovering over the insertion point of the point PIO gives me:12750,35833

    I've read this page but I just don't know what to do next, lol.

    http://www.vectorlab.info/index.php?title=Absolute_Origin

  14. What if there is no poly to work with ?

    I've got a point PIO object which will be placed on a piping run. The idea is, that it will take over the settings/data from that pipeline, aslong as I place it somewhere on the pipeline. Thus the question is how to get a handle to that pipeline.

    I tried selecting that pipeline first before adding the new point PIO, but ForEahObjectInLayer doesn't seem to return much in my point PIO.

    Any suggestions ?

  15. Hey,

    Thanks for the great responses.

    I changed the space script with your suggestions and I tweaked your script to find symbols in a room.

    I do encounter a problem comparing the coordinates though. Maybe becuase the coordinates of the path are relative to the insertion point of the space object ?

    Once I get this to work I will turn around the code, so its searches all the symbols and compares them to all spaces. Because like this it checks every symbol way to many times :)

    Procedure FindSymbols;
    VAR
    SpaceHandle,PolyHandle: 	HANDLE;
    i,j:					INTEGER;
    temp_string:				STRING;
    p1x,p2x,p1y,p2y:			REAL;
    
    PROCEDURE GetSpace(ObjHandle:HANDLE);
    
    	FUNCTION GetSymbols(SymHandle:HANDLE) :BOOLEAN;
    	VAR
    		symPt:	POINT;
    		SymbolName:	STRING;
    	BEGIN
    		GetSymLoc(SymHandle,symPt.x,symPt.y);
    		SymbolName:=GetSymName(SymHandle);
    
    		IF PtInPoly(symPt.x,symPt.y,PolyHandle) AND (SymbolName <>'') THEN BEGIN
    			AlrtDialog(concat(SymbolName,': x=',symPt.x,' y=',symPt.y));
    		END;
    	END;
    
    BEGIN
    	SpaceHandle:=	ObjHandle;
    	{ space found }
    	IF SpaceHandle <> NIL THEN BEGIN
    		{ Get the path }
    		PolyHandle:=GetCustomObjectPath(SpaceHandle);
    		{
    		GetBBox(PolyHandle,p1x,p1y,p2x,p2y);
    		Message('p1x: ',p1x,', p1y: ',p1y,' p2x: ',p2x,' p2y: ',p2y);}
    
    		{ Only get all the objects in the current layer }
    		ForEachObjectInLayer(GetSymbols,0,2,0);
    	END;
    END;
    
    BEGIN
    { Loop trough each custom space object }
    ForEachObject(GetSpace,((PON='TDE_Space')));
    END;
    
    Run(FindSymbols);

  16. Well,

    The name is unique and does get checked before added, but still I can't name any objects inside a PIO besides the path of the 2d path object. With getobject I check it to return NIL ( which it does ), but it doesn't add the name to the fresh polyline. I guess its impossible then :(

    Why and how I want it to work:

    -space 2d object lets you make a frame for a room.

    -Popup asks a roomnumber and name ( these together form the name )

    -The name gets inserted in the polyline of the object ( which I can't manage)

    -After that, another script will get trough all the spaces and use the name as a location criteria, so it can select all symbols in that space.

    PtInPoly can't be used for it, as the PIO isn't a standalone poly.

    PROCEDURE objectos;
    
    CONST
    kObjXPropSpecialEdit = 3;
    kReshapeSpecialEdit = 3;
    kObjXIs2DSurfaceEligible = 14;
    kObjXPropEditGroup = 1;
    kObjXPropEditGroupPath = 2;
    kObjOnInitXProperties = 5;
    kResetEventID = 3; 
    
    VAR
       theEvent, theButton :LONGINT;
       status :BOOLEAN;
    
    PROCEDURE Main;
    VAR
    pathHd,objHd,objrecHd,wHd,PHd,TempHd 	:HANDLE;
    result					:BOOLEAN;
    objName				:STRING;
    
    num_vertices,i			:INTEGER;
    seg_angle				:REAL;
    dir_vec				:VECTOR;
    
    v1x,v1y,v2x,v2y,mx,my		 :REAL;
    t1x,t1y,t2x,t2y,tdx,tdy		:REAL;
    x,y					:REAL;
    vertexType :INTEGER;
    vertexRadius :REAL;
    
    ShowDN				:BOOLEAN;
    positie,i_DN,FontSize		:INTEGER;
    
    request1,request2,result1,result2,RuimteNaam,RuimteNummer:STRING;
    name,klasse,temp: STRING;
    
    BEGIN
    { retrieve plug-in object information }
    result:= GetCustomObjectInfo(objName,objHd,objrecHd,wHd);
    
    { if the plug-in object info was successfully retrieved }
    IF result THEN BEGIN
    
    	{ retrieve the parameter settings for the object }
    	RuimteNaam	:= PSPACENAME;
    	RuimteNummer	:= PSPACENUMBER;
    
    	{ Juiste klasse selecteren }
    	klasse:='TDE-60 sanitair-koud';
    	NameClass(klasse);
    
    	{ obtain a handle to the path polygon of the object }
    	pathHd:= GetCustomObjectPath(objHd);
    
    	{ get the number of vertices in the path }
    	num_vertices:= GetVertNum(pathHd);
    
    	{ draw the piping lines and text label }
    	BeginPoly;
    
    	IF num_vertices = 2 THEN BEGIN
    		i:=2;
    		GetPolyPt(pathHd,i,v2x,v2y);
    		GetPolyPt(pathHd,i - 1,v1x,v1y);
    			MoveTo(v1x,v1y);
    			{LineTo(v2x,v2y);}
    			AddPoint(v2x,v2y);
    	END;
    	FOR i:= 2 TO num_vertices DO BEGIN
    		GetPolyPt(pathHd,i,v2x,v2y);
    		GetPolyPt(pathHd,i - 1,v1x,v1y);
    
    
    		MoveTo(v1x,v1y);
    		IF num_vertices <> 2 THEN AddPoint(v2x,v2y);
    
    
    	END;	
    	EndPoly;
    END;
    
    SetPolyClosed(LNewObj, True);
    
    request1 := 'Geef het lokaalnummer in:';
    request2 := 'Geef de ruimtenaam in:';
    
    IF RuimteNummer = '' THEN BEGIN
    	result1:=StrDialog(request1,RuimteNummer);
    	SetRField(ObjHd,ObjName,'SpaceNumber',result1);
    END
    ELSE BEGIN
    	result1:=RuimteNummer;
    END;
    IF RuimteNaam = '' THEN BEGIN
    	result2:=StrDialog(request2,RuimteNaam);
    	SetRField(ObjHd,ObjName,'SpaceName',result2);
    END
    ELSE BEGIN
    	result2:=RuimteNaam;
    END;
    
    name:=concat(result1,': ',result2);
    
    TempHd := GetObject(name);
     	IF TempHd  = NIL THEN BEGIN
    	SetName(LNewObj,name);
    	Message('object name is unique, send it to the  polyline :(');
    END;
    
    {Add Text}
    HCenter(LNewObj,x,y);
    { set the text properties }
    TextSize(10);
    TextJust(2);
    TextVerticalAlign(3);
    TextOrigin(x,y);
    CreateText(name);
    
    END;
    
    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:
    	BEGIN
    		Main;
    	END;
    END;
    END;
    RUN(objectos);

  17. Adding a parameter is not what I'm looking for. I need to name an object ( the polyline in this case ) so it can be used as a location.

    I've been trying something and these are the non-working results.

    - naming the path works

    - naming the polyline doesn't work.

    So I thought I didn't have the handle right. I create a text object, get a handle to it with LNewObj and name it within the script. Doesn't work either.

    All I can name is the PIO itself, and the handle of the PIO. Everything else returns an empty name slot :(

  18. While trying to make my custom space PIO I can't manage to name the polyline inside my PIO. ( This for use of the location selection critera )

    The objecthandle will name the PIO itself, but not the polyline in it, The LNewObj doesn't do anything, and the pathHd of the object can have a name, but that's useless.

    am I overlooking smth ?

  19. I'm having no result in trying to get a custom scripted polyline to have rounded corners.

    With SetPolylineVertex() I've only been able to round the path of the object, but not the object itself.

    Should it be done with that function or should I let the script calculate the position of arcs which probably is a hassle ?

  20. Yes but that's not what I'm looking for.

    The 2d reshape tool lets you change the path but not relative to the background and other objects of the drawing.

    When you draw a rectangle/polyline from scratch you get multiple selective points to change position of each segment. That's what I'm trying to get on a custom polygon/polyline.

  21. Hey,

    I tried drawing some lines using a 2d path object with this

    I can't change the lines once they are drawn. Does it only work with shapes (rect/circle etc ) or is there someting I forgot in the coding ?

    This is the script I used:

    PROCEDURE test;
    VAR
    pathHd,objHd,objrecHd,wHd	:HANDLE;
    result					:BOOLEAN;
    objName				:STRING;
    
    num_vertices,i			:INTEGER;
    seg_angle				:REAL;
    dir_vec				:VECTOR;
    
    v1x,v1y,v2x,v2y		:REAL;
    t1x,t1y,t2x,t2y,tdx,tdy		:REAL;
    
    BEGIN
    { retrieve plug-in object information }
    result:= GetCustomObjectInfo(objName,objHd,objrecHd,wHd);
    
    { if the plug-in object info was successfully retrieved }
    IF result THEN BEGIN
    
    	{ obtain a handle to the path polygon of the object }
    	pathHd:= GetCustomObjectPath(objHd);
    
    	{ get the number of vertices in the path }
    	num_vertices:= GetVertNum(pathHd);
    
    	{ draw the piping lines and text label }
    	FOR i:= 2 TO num_vertices DO BEGIN
    		GetPolyPt(pathHd,i,v2x,v2y);
    		GetPolyPt(pathHd,i - 1,v1x,v1y);
    
    		{ get the direction vector of a polygon segment }
    		dir_vec.x:= v2x - v1x;
    		dir_vec.y:= v2y - v1y;
    
    		MoveTo(v1x,v1y);
    		LineTo(v2x,v2y);
    	END;	
    END;
    END;
    Run(test);

×
×
  • Create New...