Start a new topic

Setting SMC in Script Editor applies the wrong codes

Original Post by: Mon Jun 20 19:37:40 2016


I have used the Creator Script Snippet Wizard to generate the following code for applying SMC to faces:


paramBlock = mgGetParamBlock ("Assign FID/SMC for CDB Material")

mgParamSet (paramBlock, "FID", 901)

mgParamSet (paramBlock, "SMC", 10)

mgExecute ("Assign FID/SMC for CDB Material", paramBlock)


I have updated the values of the FID and SMC to the following:


mgExecute ("Select All", None)


paramBlock = mgGetParamBlock ("Assign FID/SMC for CDB Material")

mgParamSet (paramBlock, "FID", 0)

mgParamSet (paramBlock, "SMC", 352)

mgExecute ("Assign FID/SMC for CDB Material", paramBlock)


However, when I run the code Creator sets the values to the default code snippet values of 910 and 0. Has anyone ever run across this issue before and found a fix for it? Thanks!


Edit: this was done using Creator, not Creator Pro, version 4.2.3.


Original Post by: Tue Jun 21 12:57:28 2016


The problem with your workflow is that you are trying to use a tool designed for CDB-attributed OpenFlight.The Assign FID/SMC for CDB Material tool is designed to make OpenFlight that is valid for CDB import. Because the OpenFlight is targeted for CDB, this tool imposes the range checking because for CDB OpenFlight, only FIDs and SMCs in the range I noted previously are valid.


Make sense?


Definitely. I am new to this end of the development so I definitely have some misunderstandings of the tools and their intended use. Thanks for the follow-up!

Original Post by: SteveThompson Mon Jun 20 21:54:53 2016


No worries about which forum you use...

When editing these files in the past I believe that users were going in and manually entering the desired FID/SMC values, and when you do that directly into the Face Attributes window there is no warning or error about constraints, so I hadn’t realized that there was a range to the values you could input.


You are correct, there is no range checking when you enter the values directly into the Face Attribute Page. That's becase at the generic OpenFlight level, Creator does not really care what these values are. BTW, that's why the workaround suggested using mgSetAttList works!


The problem with your workflow is that you are trying to use a tool designed for CDB-attributed OpenFlight.The Assign FID/SMC for CDB Material tool is designed to make OpenFlight that is valid for CDB import. Because the OpenFlight is targeted for CDB, this tool imposes the range checking because for CDB OpenFlight, only FIDs and SMCs in the range I noted previously are valid.


Make sense?

Original Post by: Mon Jun 20 21:26:55 2016


Steve,


I appreciate the fast response -- apologies for the misplaced post. I looked up the parameters and realized their constraints shortly after my original post. The "brute force way" that you posted did work, however.


When editing these files in the past I believe that users were going in and manually entering the desired FID/SMC values, and when you do that directly into the Face Attributes window there is no warning or error about constraints, so I hadn't realized that there was a range to the values you could input.

Original Post by: SteveThompson Mon Jun 20 21:18:33 2016


It looks like the Assign FID/SMC for CDB Material tool in Creator only allows FID values in the range 101 to 990 and SMCs in the range 0 to 14. All other values are ignored when you try to set them in the parameter block.


Note that mgParamSet returns a boolean status value indicating whether or not the param could be set to the value you specified. If you check this return value you will see that when called with these invalid values (0 for FID, 352 for SMC), the function b]mgParamSet is failing. And when the param could not be set, the values will be set from the last set of valid values used on the tool. From your original message, evidently those pref values were 910 and 0, respectively.


mgExecute ("Select All", None)


paramBlock = mgGetParamBlock ("Assign FID/SMC for CDB Material")

ok = mgParamSet (paramBlock, "FID", 0)

if (not ok): print "Error setting FID parameter"

ok = mgParamSet (paramBlock, "SMC", 352)

if (not ok): print "Error setting SMC parameter"

mgExecute ("Assign FID/SMC for CDB Material", paramBlock)

Original Post by: SteveThompson Mon Jun 20 20:45:08 2016


FIrst, this really is a Creator question, not really applicable to the OpenFlight API. You will get this question in front of a more applicable audience if you post on the Creator forum:

http://www.presagis.com/support_forum/viewforum/9/


Second, while we dig up the 4.2 code base to have a look, have you checked the Creator Status Log? Since the tool is not doing what you asked it to, perhaps Creator is issuing a message trying to tell you why.


Third, depending on what you are using this tool to do... If you really just want to set the selected polygons to FID 0, SMC 352, you can always do it the brute force way using this OpenFlight Script Code:


def SetFIDSMC(poly,fid,smc):

mgSetAttList(poly, fltPolyFid, fid, fltPolySmc, smc)


db = mgGetCurrentDb()

selectList = mgGetSelectList (db)

num = mgGetRecListCount (selectList)


if (num == 0):

mgSendMessage (MMSG_ERROR, "Nothing selected")

else:

for i in range (0, num):

rec,m = mgGetNextRecInList (selectList)

SetFIDSMC(rec, 0, 352)


Finally, I'll post back here shortly once I can get a Creator 4.2 environment up and running here to try to replicate your problem. I'll let you know what I find out.

Login to post a comment