Jump to content
Developer Wiki and Function Reference Links ×

Scale a mesh?


Recommended Posts

I went way outside my normal world and used vector script to create a mesh of an object which I couldn't build using standard script tools.  I built the object in Vectorworks, then exported it as a 3d vector script to get the mesh coordinates.  Then I added all that into a script that I am writing to build that part of the object.  That all works exactly as intended.  

 

BUT,  I want to be able to scale that mesh with user input.  So, I added some scaling fields into the OIP.  Cool.  All that is great, except at the mesh doesn't scale.  

 

Here's a general layout of the code:

 

BeginGroupN(groupname);
   BeginMesh;
      ClosePoly;
      *a bunch of 3d poly coordinates*
   EndMesh;
   EndGroup;

 

Now, I have tried HScale3d both just after EndMesh with LNewObj as the handle, and after EndGroup with "group name" as the handle.  Neither seems to have any effect.  Is there a step I'm missing here to scale a mesh overall?

Link to comment

It appears that HScale3D does not work on meshes.

 

Procedure Test;

BEGIN
	AlrtDialog(Concat(GetTypeN(FSActLayer)));
	HScale3d(FSActLayer, 0,0,0, 2,2,2);
End;

Run(Test);

 

Draw a rectangle, extrude it (or push/pull) and run the script. It doubles in size. Convert the solid to a mesh and run the script, It does not change size.

 

The menu commands Scale... does work on meshes, but requires the dialog box.

 

No good suggestions. Sorry.

Link to comment

OK, I found a work around that might work.  Convert the mesh to a solid, scale it, then convert back to a mesh.

 

I THINK the reason that HScale3D does not work is that under the hood a Mesh is effectively a group of 3D polys. And HScale3D does not work on groups.

 

Try this and see if it will fit your needs.

 

Procedure Test;

Var H1:Handle;
	N1:Integer;

BEGIN
	ClosePoly;
	BeginMesh;
		Poly3D(-1,0,0, 1,0,0, 0,-1,1);
		Poly3D(-1,0,0, 1,0,0, 0,-1,0);
		Poly3D(-1,0,0, 0,-1,0, 0,-1,1);
		Poly3D(1,0,0, 0,-1,0, 0,-1,1);
	EndMesh;
	N1:=AddSolid(LNewObj,LNewObj, H1);
	HScale3d(H1, 0,0,0, 2,2,2);
	DoMenuTextByName('Convert to Mesh', 0);
	
End;

Run(Test);

 

Link to comment
13 minutes ago, Pat Stanford said:

OK, I found a work around that might work.  Convert the mesh to a solid, scale it, then convert back to a mesh.

 

I THINK the reason that HScale3D does not work is that under the hood a Mesh is effectively a group of 3D polys. And HScale3D does not work on groups.

 

Try this and see if it will fit your needs.

 

Procedure Test;

Var H1:Handle;
	N1:Integer;

BEGIN
	ClosePoly;
	BeginMesh;
		Poly3D(-1,0,0, 1,0,0, 0,-1,1);
		Poly3D(-1,0,0, 1,0,0, 0,-1,0);
		Poly3D(-1,0,0, 0,-1,0, 0,-1,1);
		Poly3D(1,0,0, 0,-1,0, 0,-1,1);
	EndMesh;
	N1:=AddSolid(LNewObj,LNewObj, H1);
	HScale3d(H1, 0,0,0, 2,2,2);
	DoMenuTextByName('Convert to Mesh', 0);
	
End;

Run(Test);

 

That did the trick.  Don't even need to convert it back to a mesh.  

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...