ZBrushCentral

Import OBJ

Please show me correct way to import OBJ file to current tool in my script. This tool is in Edit mode and have polymeshes and parametric subtools

Append a Sphere3d (or Cube3d or other primitive) from your tool panel on the right. Then select that primitive and click on Import. Browse and import your OBJ and it will replace the primitive in your scene.

Sorry, but i post this topic in ZScripting Help thread. I dont understand why moderator moved it.
I mean correct way to importing obj in zscript.

Please show me correct way to import OBJ file to current tool in my script. This tool is in Edit mode and have polymeshes and parametric subtools

Sorry for moving your thread, that was my fault. I misunderstood what you were asking.

All you need to do to script OBJ import is to use [FileNameSetNext] to specify the file you want to import, then use [IPress, Tool:Import].

You can read more about ZScripting here:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/

You’ll see there is a link on that page to the Command Reference which lists all the zscript commands.

Ok. Thank you for answer :slight_smile:

The problem is more advanced :frowning:

Before I show you example i want to ask how to?:

  1. create new tool
  2. import obj file to it
  3. draw it at canvas
  4. go to edit mode.

I don’t want to use PolyMesh3d as new tool for importing because it is problems with naming. So at this time my code is:

[if,1,
[IPress, Tool:SimpleBrush]
[IPress, Color:Clear]
[FileNameSetNext, OBJ_FILE_PATH]
[IPress, Tool:Import]
[CanvasStroke, (ZObjStrokeV02n3=HVH0V0H0V1)]
[IPress, Transform:Edit]
]

And how to decript stroke drawing string:

ZObjStrokeV02n3=HVH0V0H0V1

It works well for me, but i want to understand this piece HVH0V0H0V1. Google did not help :frowning:

  1. The simplest way to create a new tool is to load one from disk. That way you have control over it and no problems with naming. Just save out the Polymesh3D Star tool as a ZTL. I use this method for some of my plugins.

  2. An imported OBJ will always replace the selected subtool if that subtool has no subdivision levels, so just use the m,ethod I outlined in my previous post.

  3. Instead of trying to use a Canvas Stroke simply use [CanvasClick].

[CanvasClick,10,10,10,20]
will draw the selected tool on the canvas.

  1. Once the tool is drawn on the canvas all you need to do is [IPress,Transform:Edit] to turn on Edit mode. [IPress,Transform:Fit] would then frame the tool.

[HR][/HR]Thanx it helps a lot!

The simplest way to create a new tool is to load one from disk. That way you have control over it and no problems with naming. Just save out the Polymesh3D Star tool as a ZTL

Can you show some example lines of code?

This code:

// ADD NEW TOOL
[IPress, Tool:SimpleBrush]
[IPress, Color:Clear]
[FileNameSetNext, OBJ_FILE_PATH]

[IPress, Tool:Import]
[CanvasClick,10,10,10,20]
[IPress, Transform:Edit]
[IPress, Transform:Fit]

Works well for me but with some interesting thing:

  1. If last tool contain PolyMesh3D (first instance, not copy) as subtool this code doesn’t work
  2. If last tool DOES NOT contain PolyMesh3D (or contain PolyMesh3D copy) this code WORKS
  3. If last tool contain Cube3D or Sphere3D (first instance) it also WORKS

So why this happens and what difference between PolyMesh3D and Cube3D?

I don’t know why that should be giving problems. It may be the particular way you are implementing the code. You’ll have to experiment to find out what is happening. That’s the joy of zscripting! :slight_smile:

:slight_smile: Thanx