Jump to content

Delete 3D of symbol


Recommended Posts

Hello @sandertb,

   You can get into a symbol definition with H = Fin3D(GetObject("SymDefName")) which will give you a handle to the first object in a named symbol definition. Then step through the object list with H = vs.NextObj(H) and test each object's 3D-ness with:    

 

H = vs.FSActLayer()
is3D = vs.GetObjectVariableBoolean(H, 650)    # 3D

 

   You may have to make a decision how to treat Layer Plane objects and 3D Plane (2D Planar) objects. Technically, Layer Plane objects which look like 2D objects, are considered 3D by the ObjVar_650 test, as are 2D Planar objects.

 

# This will keep Screen & Layer Plane (Symbol Definition Plane) objects, and exclude "classic" 3D objects (Extrudes, Sweeps, 3D Lock, 3D Polys, Solids, etc.)

H = vs.FSActLayer()
is3D = vs.GetObjectVariableBoolean(H, 650) and not vs.GetObjectVariableBoolean(H, 1161)    # 3D and not Planar

 

Use ObjVars:

   651 for 2D;

   650 for 3D;

   1160 for Screen Plane;

   1161 for Planar;

   1162 for Layer Plane

testing. You may have to craft the logic that filters out exactly what you don't want. 

 

   When you decide to delete an object, make sure you get your next object handle FIRST, before you delete anything.

 

   Additionally, you can use ForEachObjectInList() to step through a symbol's elements, but that tutorial is longer.

 

HTH,

Raymond

 

PS - There are no simple questions, and fewer simple answers.

 

  • Like 1
Link to comment

OK, this is weird. When I wrote the above, I was testing objects on a Design Layer. I just now tested the same objects inside a Symbol Definition.

 

A Layer Plane Object inside a SymDef shows in the OIP as being on the Symbol Definition plane. It displays on the 3D side of the symbol. It tests as 3D, but does not test as Layer Plane. On a Design Layer, the same object will test as 3D, AND as Layer Plane.

 

Bottom Line : Test you code very carefully.

 

Raymond

  • Like 1
Link to comment

The way I've done this is by testing object variable 1160 for screen plane.  For hybrid symbols, the screen plane is what is used to differentiate between a 3D component and a 2D component (one of the reasons that removing the screen plane in 2022 made creating a hybrid symbol out of an already existing 3D symbol much more difficult).

 

So I would go about doing this by using vs.FInGroup() on the symbol definition and stepping through with vs.NextObj() while doing a check with vs.GetObjectVariableBoolean([handle],1160).  The kind of tricky thing is that you can't just use vs.DelObject() to delete the object right away, otherwise you can't use vs.NextObj() properly.  So you instead have to copy the handle, use vs.NextObj(), then delete the object.

 

My Python is a little rusty, but I just tested the following Vectorscript in 2022 and it worked well, even with Legacy 2D Features disabled.  Searching for Screen Plane works best because then even traditionally 2D elements (such as text) can be removed from the 3D component of a hybrid symbol.

 

PROCEDURE Delete3DTest;

CONST

	kSymbolName = 'Test Symbol';

VAR

	h,h2:HANDLE;

BEGIN
	h:=FInGroup(GetObject(kSymbolName));
	WHILE(h<>NIL) DO
		BEGIN
			IF(GetObjectVariableBoolean(h,1160)=FALSE) THEN
				BEGIN
					h2:=h;
					h:=NextObj(h);
					DelObject(h2);
				END
			ELSE h:=NextObj(h);
		END;
END;

Run(Delete3DTest);

 

Link to comment

Thanks so much @MullinRJ @Jesse Cogswell, you gave me a lot more info then expected.
I'm testing the first version in Python as we speak, and it seems to work great so far!

Me and my colleagues will never have to remove our custom 3d symbol components by hand anymore when we need to share a file. This is gonna save loads and loads and loads of time, I can't thank you enough!

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