Setting Custom Mesh settings per object via command line


#1

Hi all!

To improve the workflow when desiring to set a custom, more detailed mesh setting to specific objects in the scene, I was wondering if it would be possible to do so via the command line? Therefore allowing one button or alias to be set for this operation. I have tried accessing the object properties but this specific setting does not seem to be available and I could not find any similar questions on the forum. Is it hidden somewhere else or is it just not accessible from the command line? If so, would it be possible to change the settings via scripting?

Thanks!


#2

Don’t think this is exposed via the command line… However it should be possible via a script. I have it partially working, but there is something I must be missing here - it only works if I first clear the meshes off an object (via ClearAllMeshes) and start in wireframe (so that the object does not have a render mesh to begin with. I must be missing a statement or option to replace the existing render mesh with the new ones, but I can’t find it for the moment… @dale, what am I missing here?

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

objID=rs.GetObject("Select a surface or polysurface",8+16,preselect=True)
if objID:
    obj=rs.coercerhinoobject(objID)
    #set some mesh parameters
    mp=Rhino.Geometry.MeshingParameters()
    mp.Tolerance=0.01
    mp.MaximumEdgeLength=5.0
    count=obj.CreateMeshes(Rhino.Geometry.MeshType.Render,mp,True)
    print "Number of meshes created={}".format(count)
    obj.CommitChanges() #doesn't seem to help, render mesh doesn't change

(Dale Fugier) #4

Hi @polforeman,

You are correct, there is no command line scriptable way to set an object to use a custom render mesh.

However, you can use RhinoScript do this. For example:

Sub Main()
	Dim arrObjects, strObject
	arrObjects = Rhino.GetObjects("Select objects to add smoother and slower render mesh")
	If IsArray(arrObjects) Then
		Call Rhino.EnableRedraw(False)
		For Each strObject In arrObjects
			Call Rhino.AddObjectMesh(strObject, 1, True)
		Next
		Call Rhino.EnableRedraw(True)
	End If	

End Sub

Here are a few more methods related to this:

https://developer.rhino3d.com/api/rhinoscript/

@Helvetosaur, there is no RhinoCommon support for this yet.

https://mcneel.myjetbrains.com/youtrack/issue/RH-50831

– Dale


#5

:cry:

Can you also add a method to detect if an object has a custom mesh already applied?


#6

Thanks, Dale! This works great indeed! As I see from the documentation, it only allows choosing from three different values, that is, either: Jagged and faster, Smooth and slower or Document settings? This is fine for what I needed, just wondering out of simple curiosity if the individual meshing parameters could also be defined somehow.

@Helvetosaur thank you too for your script and explanation! If it were to work completely, it seems you would be able to define the individual meshing parameters, right?

(I just mentioned the extra meshing parameters in case somebody else comes across this thread in the future and has the same question, I am otherwise very satisfied with your answers!)

Thanks!


(Dale Fugier) #7

See the “Also See” section of this help page.

https://developer.rhino3d.com/api/rhinoscript/object_methods/addobjectmesh.htm

– Dale


#8

Oh thanks! I totally missed that, sorry!


#9

Yes, it would. Unfortunately Python/RhinoCommon always seems to be behind Rhinoscript, which is a mystery to me, as Grasshopper is based on RhinoCommon, and I would have thought that that would be driving it in advance of things…