Fuge Posted September 12, 2023 Share Posted September 12, 2023 Hey Guys... Here I am again looking for something that's probably not doable.. But I'm throwing it out there... either I'm not seeing a way to do it, or can't find the functions to data tag an object. What I'm thinking.... 1. Select a viewport. 2. Run the script..... 3. All objects within the selected viewport, assigned to a particular class, are automatically data tagged... *** when you have a bunch of viewports and everything in each needs a tag this would be a monster time saver *** Any insight.. ideas... is appreciated... Thanks Dave 1 Quote Link to comment
spettitt Posted September 13, 2023 Share Posted September 13, 2023 I'm working on a similar script at the moment, albeit in Python. So far, I've gotten it near enough working in a design layer, and the next stage is to do it in VP Annotations. I'm not sure if VS:AddVPAnnotationObject would be enough, since it wouldn't know the handle of the specific object to be tagged. I imagine you (we!) would need the handle of the viewport and then to traverse inside the Annotations Group using VS:GetVPGroup and find the handle of the object(s) in question. To simply add a data tag, here's the small test function I've been using so far: def tag(h): vs.AlrtDialog('Found Truss') newtag = vs.CreateCustomObjectN('Data Tag', 0,0, 0, False) vs.AlrtDialog('tag made') vs.SetPluginStyle(newtag, 'Truss Tag') vs.DT_AssociateWithObj(newtag, h) So essentially - place the tag using CreateCustomObjectN, choose the style, then associate it with the object handle. It generates all of them at the origin at the moment though, so I'll be working on setting the locations per tag soon. 1 Quote Link to comment
Fuge Posted September 14, 2023 Author Share Posted September 14, 2023 Okay... I should of realized that Data Tag is a pio. Knowing that here is the concept and example. Hopefully useful to others... I plan to tweak this further, but it shows it can be done. See the attached file as well, the procedure is on a script palette with a VP to look at.. Thanks Dave Procedure Taggit; VAR viewportHandle,VPGroupH, VPObject:HANDLE; VPName:STRING; ObjName:STRING; PROCEDURE TagObj(H:HANDLE); CONST TagName = 'Code Tag'; LeaderAbove = 250mm; LeaderRight = 100mm; KVerticalOffset = 100mm; VAR DataTagH,ObjectH,VPObject :HANDLE; StyleBoo, TagBoo,AnnoBoo :Boolean; TagX, TagY,x1,y1,x2,y2, pX, pY:REAL; ObjectTop, ObjectTopInSpace, ObjectCenter, ObjectCenterInSpace, LeaderX, LeaderY :REAL; BEGIN GetBBox(H,x1,y1,x2,y2); ObjectTop:=y2; ObjectTopInSpace:= (y1); ObjectCenter:= (x2-x1)/2; ObjectCenterInSpace:= ((x2-x1) + x1) - ((x2-x1)/2); DataTagH := CreateCustomObjectN('Data Tag', 0 ,0 ,0, False); StyleBoo := SetPluginStyle(DataTagH,TagName); TagBoo := DT_AssociateWithObj(DataTagH,H); AnnoBoo:= AddVPAnnotationObject( viewportHandle, DataTagH); DataTagH:= Lnewobj; LeaderY:= ObjectTopInSpace+LeaderAbove; LeaderX:= ObjectCenterInSpace+LeaderRight; HMove(DataTagH, LeaderX, LeaderY ); {Leader above center of object } SetRField(DataTagH,'Data Tag','__RefOffsetX',Num2StrF(Round(ObjectCenter))); { Move horizontal } SetRField(DataTagH,'Data Tag','__RefOffsetY',Num2StrF((ObjectTopInSpace-KVerticalOffset))); { Moves vertical } SetRField(DataTagH,'Data Tag','Horizontal Position','Right'); { Default side the leader is placed } SetRField(DataTagH,'Data Tag','World-based','False'); ResetObject(DataTagH); END; BEGIN ViewportHandle := LSActLayer; If ViewportHandle=NIL THEN BEGIN AlrtDialog('Select a viewport!'); Sysbeep; END ELSE BEGIN VPGroupH:= GetVPGroup( viewportHandle,2); VPObject := FInGroup(VPGroupH); { The record criteria, class, etc to tag } ForEachObject(TagObj,((R IN ['Nimlok DB']) &(C='STEP-1') & (T<>LIGHT))); VPObject := NextObj(VPObject); UpdateVP( ViewportHandle); Redrawall; END; END; Run(Taggit); AutoDataTag.vwx 3 Quote Link to comment
KingChaos Posted November 6, 2023 Share Posted November 6, 2023 hi there, sounds interesting to me. I would like to datastamp all existing parts > in a secific viewport on a specific layout-Layer. Is that possible? my bad i only have a vw22 so i cant look into the vwx file. BR KC Quote Link to comment
Fuge Posted November 7, 2023 Author Share Posted November 7, 2023 Hey KingChaos, See the attached... The attached is saved back to VW22... But not tested there... HTH .. A lot more development is being worked on for this... Something I'll post in the future.. Procedure Taggit; VAR viewportHandle,VPGroupH, VPObject:HANDLE; VPName:STRING; ObjName:STRING; PROCEDURE TagObj(H:HANDLE); CONST TagName = 'Code Tag'; LeaderAbove = 250mm; LeaderRight = 100mm; KVerticalOffset = 100mm; VAR DataTagH,ObjectH,VPObject :HANDLE; StyleBoo, TagBoo,AnnoBoo :Boolean; TagX, TagY,x1,y1,x2,y2, pX, pY:REAL; ObjectTop, ObjectTopInSpace, ObjectCenter, ObjectCenterInSpace, LeaderX, LeaderY :REAL; BEGIN GetBBox(H,x1,y1,x2,y2); ObjectTop:=y2; ObjectTopInSpace:= (y1); ObjectCenter:= (x2-x1)/2; ObjectCenterInSpace:= ((x2-x1) + x1) - ((x2-x1)/2); DataTagH := CreateCustomObjectN('Data Tag', 0 ,0 ,0, False); StyleBoo := SetPluginStyle(DataTagH,TagName); TagBoo := DT_AssociateWithObj(DataTagH,H); AnnoBoo:= AddVPAnnotationObject( viewportHandle, DataTagH); DataTagH:= Lnewobj; LeaderY:= ObjectTopInSpace+LeaderAbove; LeaderX:= ObjectCenterInSpace+LeaderRight; HMove(DataTagH, LeaderX, LeaderY ); {Leader above center of object } SetRField(DataTagH,'Data Tag','__RefOffsetX',Num2StrF(Round(ObjectCenter))); { Move horizontal } SetRField(DataTagH,'Data Tag','__RefOffsetY',Num2StrF((ObjectTopInSpace-KVerticalOffset))); { Moves vertical } SetRField(DataTagH,'Data Tag','Horizontal Position','Right'); { Default side the leader is placed } SetRField(DataTagH,'Data Tag','World-based','False'); ResetObject(DataTagH); END; BEGIN Layer('View-1'); { Example Go to the layer you want by its name } ViewportHandle := GetObject('MyViewPort'); { Example - Get the Viewport you want be name, giving you a handle to it } If ViewportHandle=NIL THEN BEGIN AlrtDialog('Select a viewport!'); Sysbeep; END ELSE BEGIN VPGroupH:= GetVPGroup( viewportHandle,2); VPObject := FInGroup(VPGroupH); { The record criteria, class, etc to tag } ForEachObject(TagObj,((R IN ['Nimlok DB']) &(C='STEP-1') & (T<>LIGHT))); VPObject := NextObj(VPObject); UpdateVP( ViewportHandle); Redrawall; END; END; Run(Taggit); AutoDataTag_v2022.vwx Quote Link to comment
KingChaos Posted November 7, 2023 Share Posted November 7, 2023 mega danke, mal sehen wann ich zeit habe das umzusetzen Quote Link to comment
fispol01 Posted December 16, 2023 Share Posted December 16, 2023 Unfortunatly, doesn't work in 2D plan.... 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.