Error warning without scripting error? (Surface renaming)

Strange problem here: I'm trying to rename the G8 Surface "Torso" to G8.1 Surface "Body" (for a Geoshell). The script does what it should (without errors) - but I still get the message "Error: Result of expression fFind[null] is not an object " after the script has finished.

I'm not a great programmer, but I think I understand what's going on in most cases. I have found the snippet that I use for finding / renaming the Surface several times here in the forum ... without reference to the error message. So I must be doing something wrong. Here is the snippet:


var oShape = geoShellOBJ.getObject().getCurrentShape();

var oDZMaterial = oShape.findMaterial('Torso');

if (oDZMaterial) { ... }

The "if" triggers the error warning. I have tried it with everything possible (if (! oDZMaterial) etc. ... but the error message still appears. Strange - and like said before: this is the way others suggested.

Since it is a commercial project, I would like to remove the error message. Does anyone have any tips? Sorry in advance if I am late in getting back to you. I have a lot to do at the moment.

Here the forum threads with the snippets (and without reference to possible error messages):
https://www.daz3d.com/forums/discussion/547276/how-to-change-surface-name-by-using-script-correctly
https://www.daz3d.com/forums/discussion/365736/unable-to-define-surfaces-for-a-geoshell

Additional info:
the script runs “save” (within an empty function), the version is // DAZ Studio version 4.15.0.2 file type DAZ Script

Comments

  • Error: Result of expression fFind[null] is not an object  - fFind?

  • Richard Haseltine said:

    Error: Result of expression fFind[null] is not an object  - fFind?

    Yes - I just put on a pair of glasses: is “fFind” when using "oShape.findMaterial('Torso')"

  • OmnifluxOmniflux Posts: 377

    Not related to the error, and you haven't stated your end goal, but wanting to rename 'Torso' to 'Body' on a GeoShell suggests you may actually want to be using a 'Surface Selection Set' instead (described in the second half of section 3.5 in the User Guide).

    I posted a script that adds the Genesis 8 Legacy set to a Genesis 8.1 GeoShell in the thread Batch process G8 geoshell presets to G8.1 a few years ago that you may want to look at, also related is the script I posted in the thread Geoshell setup script?

  • Yes, a Geometry Shell is the same mesh as the source, albeit with its own surface settings - you cannot edit its groups or other basic aspects.

  • @ Omniflux:

    Yes, I know your perfect geoshell scripts - they led me to the light during my first steps :)

    Of course, I have already tried “Legacy” - which led to errors for me, as I don't have “Legacy” ... i.e. customers without “legacy” will receive the same error message.

    The goal of the script is to rename the “Torso” Surfaces of a GF8 Geoshell to “Body” (GF8.1) in order to use the already finished Material Presets (85!) that I have developed for GF8.1. This works perfectly (i.e. I can rename GeoShell Surfaces) ... only at the end - when the script is finished - I get the error.

    @ Richard Haseltine

    As mentioned in the thread opener and just said again: the script renames a GF8 Geoshell Surface “Torso” to “Body” without any problems and I can assign material presets, property presets etc. that were developed for GF8.1 (“Body”) Geoshells. Only at the end - i.e. when the renaming has been successful - the error message appears ... although the script runs through.

    ------------------------

    Looks like I'll have to live with the error (or error message) for the time being and explain to my customers why it's occurring. It's a bit more paperwork and explanation work ... but my customers are already used to that from me ;-)

    Many thanks for your comments :)

     

Sign In or Register to comment.