Jump to content

Jord Visser

Member
  • Posts

    16
  • Joined

  • Last visited

Posts posted by Jord Visser

  1. I'm trying to set-up a PIO with support for 'red' symbols.

    I tried digging trough the SDK files to find out how to handle all the different events that get emitted during Object Style actions, but so far I'm unable dissect what to do on which event.

    Looking in MiniCadCallBacks.h for my guidance at the moment...

     

    Is there a walkthrough of what to do at which event?

  2. @JBenghiat FIn3D did the job, looking back in the documentation 'Handle to first item in list' on the ForEachObjectInList() function should have given it away to me..

    Thanks for the help!

     

    As a little gift, my Python generator wrapper for ForEach* functions with a callback as the first argument:

    The first argument is the VS function, followed by all of its parameters

    class callback_iter:
    	def __init__( self, func, *args ):
    		self.objects = []
    		self.sentinel = object( )
    		
    		def _callback( handle ):
    			self.objects.append( handle )
    			
    		func( _callback, *args )
    		self.objects.append( self.sentinel )
    		
    	def __iter__( self ):
    		return self
    	
    	def __next__( self ):
    		while True:
    			if len(self.objects) > 0:
    				obj = self.objects.pop(0)
    				if obj is self.sentinel:
    					raise StopIteration()
    					break
    				else:
    					return obj
                                                             
    
    for object_handle in callback_iter( vs.ForEachObjectInList, 0, 2, FirstHandleInList ):
      #do some magic

     

  3. I'm working on a plug-in that generates a lot of bitmaps from symbols.

    To make it more user friendly i'm using the previously generated bitmaps in the PIO as a cache, I do this by setting kObjXPropPreserveContents to True and only delete out-of-date objects at redraw.

     

    I tried using ForEachObjectInList starting at the PIO handle with deep traversal and start ignoring the callbacks once an object which does not have the PIO as parent.

    The problem with this method is that once my object is not the front most object in the document the ignored callbacks start stacking up, the more backward the PIO placement is the more processing time the plug-in needs.

     

    I'm now resorting to FInSymDef and NextObj, but NextObj never goes to None... so it feels like this is not the definitive method for what I need.

     

    Is there any other way to loop over ONLY the items in the group of the PIO that is really scoped to the PIO?

    And without having to check the parent of each of the looped objects 😉 [edit for more clarity]

     

    With kind regards,

    Jord Visser

  4. 24 minutes ago, JBenghiat said:

    You've defined LTSymbol as your main procedure, so any other procedures need to be inside that scope, i.e. place sub-procedures after the main procedure's TYPE, CONST, and VAR sections.  Refer to the VS language guide for information on scope: http://developer.vectorworks.net/images/7/72/VectorScriptGuide.pdf

     

    Thanks for the quick reply! works as a charm.

     

    Makes a lot of sense now, quickly read trough the mentioned document a couple of times before.. I think it's time to read it thoroughly.

  5. Hi all,

     

    I'm made a rough PIO in vectorscript yesterday, this morning I added a procedure and it keeps getting stuck on a compiling error.

    I rewrote the function several times now, checked all the IF-ELSE's, WHILE's and BEGIN's and I keep falling back to this error.

     

    The MakeGrayObject Procedure is the one I added this morning

     

    The error is:

    Line #42: PROCEDURE LTSymbol;
    { Error: Extra text at end of script; missing BEGIN statement? }
    { Error: Identifier not declared. }

    I attached the pascal .txt file and the .vso, both only tested in VW2018.

     

    Can someone help me with this?

     

    With kind regards,

    Jord Visser

    ltsymbol.txt

    [LT] Advanced symbol.vso

  6. I think i know what is happening.

    I looks to me that the viewport logic first updates the annotation group before updating the crop object.
    I think this is due to the fact that the annotation group is needed to create the selection group.

    I'm going to try to save the state of the viewport within the plug-in and compare this on redraw to get to know if the parametrics of the viewport changed.

    Are there any core developers over here whom can explain the inner workings of the viewport object?

  7. Just now, JimW said:

    Yes, theres a day or so in there that were missed, but if trying to grab it risks the rest of the content we won't be attempting recovery. Apologies, there were some holdups in migration that caused it.

    No problem. The upgrade gave a lot in return :)

    Thanks!

  8. Hi all,

     

    I'm making a plug-in which needs knowledge of the exact viewport-crop position in relation to the plug-in position in the Annotation group of the viewport, when moving/rotating the viewport a problem occurs.

     

    I attached a sample document & the .vso plugin.

    How to replicate the problem:

     - Have a viewport with and crop object

    - Place the plug-in in the annotation group of this viewport

    - exit the annotation group

    - move / rotate de viewport

     

    	PROCEDURE CropDupeTest;
    VAR
        result                                    :BOOLEAN; {temporary store for BOOL results}
    	    objectName                                :STRING;
        objectHandle, recordHandle, wallHandle    :HANDLE;
        
        eventInfo, eventType                    :LONGINT;
        pluginObjectExists                        :BOOLEAN;
        
        pluginRotation                            :REAL;
        pluginPosition                            :VECTOR;
    	    vpRotation                                :REAL;
        vpPosition                                :VECTOR;
        vpScale                                    :REAL;
        
        vpCropObject                            :HANDLE;
        bbHandle                                :HANDLE; {copy of crop object into plugin}
        
        x, y, z                                    :REAL;
        is3D                                    :BOOLEAN;
        
        userShowUnitMark                        :BOOLEAN;
        docUnitsPerInch                            :REAL;
    	
    PROCEDURE reDraw;
    BEGIN
        Rect(-5m,-5m, 5m, 5m);
        Locus(0, 0);
        
        TextJust(2);
        TextVerticalAlign(3);
        
        MoveTo(0, 1m);
        CreateText('Plugin');
        
        MoveTo(0, -1m);
        CreateText('Origin');
        
        result := vsoStateGetPos( objectHandle, x, y, z, is3D );
        MoveTo(0, -2m);
        CreateText( Concat('Object movement=', result,'  offset=(x=', x, ', y=', y, ', z=', z, ') is3DMove=', is3D ) );    
        SetTextStyle(LNewObj, 0, GetTextLength(LNewObj), 2);
    END;
    	PROCEDURE setBaseVariables;
    BEGIN
        vpCropObject := NIL;
    END;
    	PROCEDURE loadBaseInfo;
    BEGIN
        GetSymLoc(objectHandle, pluginPosition.x, pluginPosition.y);
        pluginRotation := GetSymRot(objecthandle);
                        
        {not used}
        vpScale := GetObjectVariableReal(GetVPGroupParent(GetParent(objectHandle)), 1003);
        vpPosition.x := GetObjectVariableReal(GetVPGroupParent(GetParent(objectHandle)), 1024);
        vpPosition.y := GetObjectVariableReal(GetVPGroupParent(GetParent(objectHandle)), 1025);
        vpRotation := GetObjectVariableReal(GetVPGroupParent(GetParent(objectHandle)), 1026);
        docUnitsPerInch := GetPrefReal(152);
    END;
    	PROCEDURE loadCropObject;
    BEGIN
        IF VPHasCropObject(GetVPGroupParent(GetParent(objectHandle))) THEN BEGIN
            vpCropObject := GetVPCropObject(GetVPGroupParent(GetParent(objectHandle)));
                
            bbHandle := ConvertToPolygon(vpCropObject, 30);
            HMove(bbHandle, -pluginPosition.x, -pluginPosition.y);
            HRotate(bbHandle,  0, 0, -pluginRotation);
        END;
    END;
    	BEGIN
        {Store & adjust user settings}
        userShowUnitMark := GetPref(163);
        SetPref(163, FALSE);
        PushAttrs;
        
        setBaseVariables;
        
        pluginObjectExists := GetCustomObjectInfo(objectName, objectHandle, recordHandle, wallHandle);
        vsoGetEventInfo(eventType, eventInfo);
        
        CASE eventType OF
            5: {kObjOnInitXProperties}
            BEGIN
                SetPrefInt( 590, 1 ); {varParametricEnableStateEventing, kParametricStateEvent_ResetStatesEvent}
                result := SetObjPropVS(18, TRUE); {kObjXPropAcceptStates}
                
                {fallback to ensure good redraw before export}
                result := SetObjPropVS(23, TRUE); {kObjXPropResetBeforeExport}
            END;
    	        44: {kObjOnAddState}
            BEGIN
                eventInfo := vsoStateAddCurrent( objectHandle, eventInfo );
            END;
    	        45: {kObjOnContextMenuInit}
            BEGIN
                {.......}
            END;
    	        46: {kObjOnContextMenuEvent}
            BEGIN
                {.......}
            END;
    	        3: {kParametricRecalculate}
            BEGIN
                IF pluginObjectExists THEN BEGIN
                    IF NOT GetPref(531) THEN BEGIN
                        IF objectHandle <> NIL THEN BEGIN
                            IF NOT IsNewCustomObject(objectName) THEN BEGIN
                                SetObjectVariableBoolean(objectHandle, 800, TRUE); {Accept text styles}
    	                            loadBaseInfo;
                                loadCropObject;
                                reDraw;
    	                            IF vpCropObject <> NIL THEN BEGIN
                                    {Temporary crop duplicate placement for visibility}
                                    HMoveBackward(bbHandle, TRUE);
                                    SetFPat(bbHandle, 0);
                                    
                                    {Clean up the crop duplicate after use}
                                    {DelObject(bbHandle);}
                                END;
                            END;
                        END;
                    END ELSE BEGIN
                        Rect(-1m, -1m, 1m, 1m);
                    END;
                END;
    	            vsoStateClear(objectHandle);
            END;
        END;
    	    {Restore user settings}
        PopAttrs;
        SetPref(163, userShowUnitMark);
    END;
    Run(CropDupeTest);
    	

    [LT] Crop Dupe Test.vso

    crop_dupe_test.vwx

  9. Hi Dieter,

    Thanks for your response!

    I already made some proof of concept plug-ins in vectorscript, but with the size and complexity of these programs vectorscript starts to become very annoying.. so the step to python was just a matter of time, so thanks for the extra push towards python ;)

    Your API looks as a very good base, too bad I am stuck with 2014 for the foreseeing future. But I will certainly use it as a guide for my journey!

    As for the developer mode, I am indeed working with an english version.. so I will keep looking into the help-files and other resources.

    On the subject of importing/including it seems to me that the way newlines are handle matters as well, I had to use CR+LF to get it to 'work'

    Gr,

    Jord

  10. I'm sort of new in vectorscript pio coding and have a couple of questions:

    - Where can i turn on 'developer mode' in vw2014?

    - Is there an good example available with all the different widgets that can be used in the shape pane?

    - What are the encoding and newline requirements for files I want to include via $INCLUDE ?

    Gr,

    Jord

×
×
  • Create New...