Jump to content
Developer Wiki and Function Reference Links ×

Problem with "ForEachObjectAtPoint".


Recommended Posts

Hi everyone,
I'm having a problem with the "ForEachObjectAtPoint" function.
I need to explore one of the objects and define its object type.
The script I created works fine on design layers.
It behaves strangely in ViewPorts. If I'm in top view, it works, but if I'm in another view, it doesn't.
Does anyone have any ideas?
Thanks everyone

 

 

Procedure Taggit;
{Creato il 26 /03/2026}

VAR
    Scala                         :REAL;
    g                            :POINT;
    viewportHandle,VPGroupH        :HANDLE;
    proseguo,proseguo2            :Boolean;
    Tipo_L                        :INTEGER;


FUNCTION IN_VPort(h1 :HANDLE) :BOOLEAN;
VAR
    tmp_B            :BOOLEAN;
    tag                :string;
    DataTagH        :HANDLE;
BEGIN
    tag:=Num2Str(0,GetTypeN(h1));
    TextOrigin(g.x*Scala, g.y*Scala);
    TextSize(10*Scala);
    CreateText(tag);
    DataTagH := LNewObj;
    tmp_B:= AddVPAnnotationObject( viewportHandle, DataTagH);
    proseguo2:=True;
    ReDraw;
END;
{fine funzione per ViewPort}

FUNCTION IN_Lucido(h1 :HANDLE) :BOOLEAN;
VAR
    tag                :string;
    DataTagH        :HANDLE;
BEGIN
    tag:=Num2Str(0,GetTypeN(h1));
    TextOrigin(g.x, g.y);
    TextSize(10);
    CreateText(tag);
    DataTagH := LNewObj;
    proseguo2:=True;
    ReDraw;
END;
{fine funzione per Lucido}
BEGIN
    proseguo2:=false;
    Tipo_L:=GetObjectVariableInt(ActLayer, 154); {message ('tipo lucido :',ii,' Nome :',GetLName(ActLayer));}
    Case Tipo_L of
    1:BEGIN  {lucido design}
        Scala:=GetLScale(ActLayer);
        proseguo:=True;
        WHILE proseguo=TRUE DO BEGIN
            GetPt(g.x,g.y);
            ForEachObjectAtPoint(IN_Lucido, 0, 1, g.x, g.y, 0.05);
            if (proseguo2=True) THEN
            begin
                proseguo:=YNDialog('Continuo?');
            end else BEGIN
                proseguo:=YNDialog('nessun oggetto selezionato. Continuo?');
            end;
        end;
    end;
    2:BEGIN     {lucido presentazione}
        ViewportHandle := LSActLayer;
        Scala:=GetObjectVariableReal(ViewportHandle, 1003);
        If ViewportHandle=NIL THEN
        BEGIN
            AlrtDialog('Seleziona una viewport!');
            Sysbeep;
        END ELSE BEGIN
            VPGroupH:= GetVPGroup( viewportHandle,2);
            proseguo:=True;
            WHILE proseguo=TRUE DO BEGIN
                GetPt(g.x,g.y);
                ForEachObjectAtPoint(IN_VPort, 1, 1, g.x, g.y, 1);
                if (proseguo2=True) THEN
                begin
                    proseguo:=YNDialog('Continuo?');
                end else BEGIN
                    proseguo:=YNDialog('nessun oggetto selezionato. Continuo?');
                end;
            end;
            ResetBBox(VPGroupH);
            UpdateVP( VPGroupH);
            ResetObject(VPGroupH);
        END;
    end;
    OTHERWISE
        BEGIN
            {x completezza} 
        end;
    end;    
    Redrawall;
END;

Run(Taggit);

Test.vwx

Link to comment

Hi everyone,
I think I solved the problem in a somewhat unstructured way.
1. I create a resource list with the layers using BuildResourceList
2. From that list, I remove the layers that aren't in the VP using GetVPLayerVisibility
3. With an active loop, I select the VP layers one at a time, setting the same view as the VP using SetViewMatrix, on which I execute ForEachObjectAtPoint
It seems to work.

 

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