DrawCircle for 3D (aka hollow cylinder)

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
ptis
Posts: 28
Joined: Wednesday 16 May, 2012 - 10:18

DrawCircle for 3D (aka hollow cylinder)

Post by ptis »

Hello,

I want to draw a hollow cylinder respectively a cylinder with a inner radius (like in the DrawCircle-Command).

Is there any way to do that without a 3D-Model or a Mesh?

Background: I need this for a better looking Curved Conveyor, but the Mesh from the normal conveyors doesn'l look good enough and I have problems to scale them right.

Thanks
BartC
Posts: 47
Joined: Monday 05 November, 2012 - 17:05

Re: DrawCircle for 3D (aka hollow cylinder)

Post by BartC »

Hello ptis,

You can use the following code to draw a cylinder:

Code: Select all

DrawCylinder(
  0,       {X-Location from Atom origin}
  0,       {Y-Location from Atom origin}
  0,       {Y-Location from Atom origin}
  20,      {Height, 50 % in positive z-direction, 50% in negative z-direction}
  10,      {Radius in X-direction} 
  10,      {Radius in Y-direction} 
  360,     {Angle of the cylinder (360 for a complete round cylinder)}
  Z_AXIS,  {Axis around which the cylinder is drawn}
  CP_SIDES + CP_BOTTOM + CP_TOP {Which sides are drawn. Only use CP_SIDES for a hollow cylinder}
)
Regards,

Bart
BartC
Posts: 47
Joined: Monday 05 November, 2012 - 17:05

Re: DrawCircle for 3D (aka hollow cylinder)

Post by BartC »

Hello ptis,

I thought about your idea of having an inner radius on a cylinder and came up with a solution. In the attached model, you can find the 4DScript to draw a hollow cylinder on the On3DDraw event of the product. Play with the variables to adjust the shape of your cylinder.

Regards,

Bart
Attachments
Hollow Cylinder.mod
(4.2 KiB) Downloaded 320 times
ptis
Posts: 28
Joined: Wednesday 16 May, 2012 - 10:18

Re: DrawCircle for 3D (aka hollow cylinder)

Post by ptis »

Hello BartC,

a combination of Cone and Cylinder... clever idea! It works! Thanks!

But one more little question: If I rotate this model (with rotatecoords) the shading is obviously wrong. ED shades the model like it wouldn't be rotated. Is there any way to fix this? I guess the only way is to do the "RotateCoords" by myself and don't use the ED-RotateCoords?

Thanks
ptis
Posts: 28
Joined: Wednesday 16 May, 2012 - 10:18

Re: DrawCircle for 3D (aka hollow cylinder)

Post by ptis »

*bump*
ptis wrote:But one more little question: If I rotate this model (with rotatecoords) the shading is obviously wrong. ED shades the model like it wouldn't be rotated. Is there any way to fix this?
Post Reply