Select only vertical faces of the EditableMesh object

Is there any solution to select vertical faces of the Editable Mesh object?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
harumscarum's picture

ChatGPT did the job, however

ChatGPT did the job, however it do not know how to select faces, may only delete it
and it is slow

-- Assuming you have the EditableMesh object selected
obj = selection[1]
 
-- Get the number of faces
numFaces = obj.numFaces
 
-- Iterate through faces in reverse order
for f = numFaces to 1 by -1 do
(
    -- Get the normal of the face
    faceNormal = getFaceNormal obj f
 
    -- Check if the face is vertical
    if dot faceNormal [0, 0, 1] < 0.99 do
    (
        -- Delete the face
        deleteFace obj f
    )
)
miauu's picture

.

The code you have will delete bottom faces of a box primitive converted to Editable Mesh.

(
	obj = selection[1]	
	if classOf obj == Editable_mesh do
	(
		vertFacesBA = #{}
		numFaces = obj.numFaces
		for f = 1 to numFaces where ( dot (fNormal = getFaceNormal obj f) [0, 0, 1] < 0.99 ) and (dot fNormal [0,0,1] > -0.99) do vertFacesBA[f] = f		
		if vertFacesBA.numberset != 0 then
		(
			select obj
			max modify mode
			subobjectlevel = 3
			setFaceSelection obj vertFacesBA
		)
		else
			messagebox "No vertical faces has been found" title:""
	)
)
jahman's picture

.

it might be faster to use abs to make just a single value comparison
like that:

...
for f = 1 to numFaces where (abs (dot (getFaceNormal obj f) z_axis)) < 0.99 do vertFacesBA[f] = true
...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.