g5 Molinengo Posted March 31 Share Posted March 31 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 Quote Link to comment
Pat Stanford Posted April 1 Share Posted April 1 I have not looked at your code, but take a look at the three FindObjectAtPt_ commands (Create, GetCount, GetObject). I think you will find that they are more flexible and may work in your situation. Quote Link to comment
g5 Molinengo Posted April 2 Author Share Posted April 2 Thanks but I tried "FindObjAtPt_Create" it seems to ignore all 3D objects and VPs Quote Link to comment
g5 Molinengo Posted April 8 Author Share Posted April 8 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. Quote Link to comment
Recommended Posts
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.