Digital Art Zone

 
     
Not working arrays for Facet. Why?
Posted: 12 November 2012 04:39 AM   [ Ignore ]
New Member
Avatar
Total Posts:  10
Joined  2005-03-28

What wrong in this code? I’m try to get vertexes in current facet.

m_normIdx [4], m_uvwIdx [4] also don’t working :(


var oNode = Scene.getPrimarySelection();
if( oNode ){
var oObject = oNode.getObject();
var oShape = oObject.getCurrentShape();
var oGeometry = oShape.getGeometry();
var oFacet = oGeometry.getFacet(0);
for( k = 0; k < 4; k++ ) {
  var currentVertex = oGeometry.getVertex(oFacet.m_vertIdx[k]);
                                                                      ~~~~~~~~~~~~~~~
}
}

TypeError: Result of expression ‘oFacet.m_vertIdx’ [undefined] is not an object.

Profile
 
 
Posted: 12 November 2012 06:17 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13921
Joined  2003-10-09

Edit - while I stand by my advice below, you should also check the type of oGeometry. I don’t see getFacet() in the DS 3 scripting docs, and I don’t see m_vertIdx as a member of any of the facet types which may be your biggest problem - it isn’t defined by you either.

—————————————————————————-

Try adding some error checking - I suspect you’re being too trusting and not ending up with a facet.

var oNode Scene.getPrimarySelection();
if( 
oNode ){
 
var oObject oNode.getObject();
 if (
oObject{
  
var oShape oObject.getCurrentShape();
  if (
oShape{
   
var oGeometry oShape.getGeometry();
   if (
oGeometry{
    
var oFacet oGeometry.getFacet(0);
    if (
oFacet{
     
for( 04k++ ) {
      
var currentVertex oGeometry.getVertex(oFacet.m_vertIdx[k]);
                                                                      ~~~~~~~~~~~~~~~
     
}
    }
    
else {
     
print ( "No facet" );
    
}
   }
   
else {
    
print ( "No geometry" );
   
}
  }
  
else {
   
print ( "No shape" );
  
}
 }
 
else {
  
print( "No object" );
 
}
}
else {
 
print( "No node" );
 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 12 November 2012 06:41 AM   [ Ignore ]   [ # 2 ]
New Member
Avatar
Total Posts:  10
Joined  2005-03-28

Same result with checking :(

Script Error: Line 12
TypeError: Result of expression ‘oFacet.m_vertIdx’ [undefined] is not an object.


From last SDK documentation:

http://www.daz3d.com/shop/daz-studio-4-5-sdk

file:
C:\Program Files\DAZ 3D\DAZStudio4 SDK\docs\class_dz_facet.html

—-
DzFacet Class Reference
[Object and Geometry Classes]

Represents a polygonal face. More…

Public Attributes
...
int m_normIdx [4]
int m_uvwIdx [4]
int m_vertIdx [4]
...
DzFacet::m_vertIdx[4]
Array of vertex indices that make up the face. m_vertIdx[3] will be -1 if this is a triangle.

 

Profile
 
 
Posted: 12 November 2012 06:51 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13921
Joined  2003-10-09

That’s the SDK, not the Scripting kit - they are not the same.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 12 November 2012 07:04 AM   [ Ignore ]   [ # 4 ]
New Member
Avatar
Total Posts:  10
Joined  2005-03-28

My fault smile

Whether there is a fresh version of Scripting kit? In DazStudio 4.5 it seems any more polygons, only triangles and quads are supported?

Profile
 
 
Posted: 12 November 2012 01:31 PM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13921
Joined  2003-10-09

There are a couple of samples related to mesh generation, which isn’t of course what you are doing but it may be helpful:
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/geometry/generate_plane/start
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/geometry/generate_sphere/start

You can also use Rob’s trick to see what members an object has:

var object = new DzWhatever// or get an example of the object type from the scene
for ( var n in object{
     
print( );
 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 07 February 2013 11:50 AM   [ Ignore ]   [ # 6 ]
New Member
Total Posts:  6
Joined  2013-02-05

Have you solved the problem yet?
Recently,my problem was how to add a single arrow to only one facet. Recently I installed a new version of R:

  platform i386-pc-mingw32
  version.string R version 2.14.2 (2012-02-29) ggplot2_0.9.0

Here is the code example
xdf <- data.frame(x=rep(1:10,each=4)
          ,y=rep(1:10,each=4)*rep(1:4,10)  +rnorm(40,0,1)
          ,g=rep(c(“R”,“S”),20)
          ,z=rep(c(“A”,“A”,“B”,“B”),10)
          )
head(xdf)
# plot
xp <- ggplot(xdf,aes(x=x,y=y, group=g)) +
geom_line() +
facet_grid(. ~ z)
xp
# location of the arrow: x=4, y=y+1 on the top of the first facet (A)
(f1x4 <- subset(xdf,x==4 & g==“R” & z==“A”)$y)
arrdf <- data.frame(x = 4, y = f1x4, z = “A”, g = “R”)  # create new data.frame for   annotations
# add arrow and label
xp + geom_segment(data=arrdf,aes(x=x,xend=x,y=y+3,yend=y,z=z,g=g)  # <—see the z=‘A’
          , arrow=arrow(length=unit(0.4,“cm”)
          )
        ) +
geom_text(data=arrdf,aes(x=x,y=y+4, label=“a”,z=z, g=g))

 Signature 

Free Picture Resize StarterPowerDVD Download

Profile