News:

Interested in some really terrific mobile apps? Visit www.turboapps.com for details.

Main Menu

3D Mesh improvements inspired by DesignCAD 3D Max

Started by murray dickinson, June 08, 2023, 06:56:40 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

murray dickinson

TC's 3D mesh could be improved using DesignCAD's connect surface and patch surface tools.  DC's connect surface lofts 3D meshes through profiles.  You can specify interpolation (how many subdivisions) between the profiles and how many segments the profiles interpolate with (it uses simplified polyline segmentation for automatic approximation of curve profiles and even dense polylines because it's producing meshes), and there's a choice of ruled surface, curved through the profiles, or smoothed overall.  Nice.  TC's 3D Mesh tool is limited to rectangular creation with the coords in world CS and hasn't had any love since being introduced in V6 (late 90s), DC's tool is completely flexible, and a surface created with it and exported as .dxf imports as a native mesh in TC, with coordinates accessible in TC's property tables.  DC's patch surface is a mesh cover surface defined by three or four 3D polyline or 3D curve edges.  The cover mesh that results is a rectangular grid, and like the connect surface, exports as a TC 3D mesh (again not restricted to rectangular) as .dxf.  Being able to create quad meshes in these ways is useful for terrain tools and to rebuild triangular surfaces like .stl models or TINs from point clouds into structured meshes especially useful for mesh to nurbs conversion, and to use the definable interpolation to smooth existing meshes.  That could also be polished into an "add loop" tool for level-zero SMESHes. 

nikkipollard

#1
I know it is not the same. It is possible to write scripts for creating complex surfaces with our sdk.

I think Kevin Chapman wrote a simple example. Using a complex formula.
Those surfaces can easily be converted to smeshes - Which can be smoothed and edited. I remember Kevins example being very slow on my old machine - but I was able to create simple meshes between splines - which didn't take as long.

I am fairly certain that your wish could be granted by one of our developers.

This is a simplified version of Kevins script - for half an ellipsoid. - which can be run in the macro recorder
Option Explicit
                                                           

'====================================================================
   '# DESCRIPTION
'Draws half an ellipsoid surface'
''ellipsoid x=a*sin(v)*cos(u),y=b*sin(v)*sin(u),z=c*cos(v)
'for u in [0,360) and v in [0,180]. - ellipsoid
'for u in [0,360) and v in [0,90] - hemisphere?
' R1 = 6378157  earth
'R2 = 6356752.314 earth
'=====================================================================
Dim tcDraw

 Call Main

Set tcDraw = Nothing


'_______________________________________________________________________________
Sub Main
     
 Set tcDraw = ActiveDrawing

Dim Major : Major = InputBox("MajorRadius","GetRadius",6378157)
  If Major = 0 Then Exit Sub                     'user cancelled
Dim Minor : Minor = InputBox("MajorRadius","GetRadius",6378157)
  If Minor = 0 Then Exit Sub                     'user cancelled
Dim Height : Height = InputBox("Height","Get height", 6356752.314)
  If Height = 0 Then Exit Sub                     'user cancelled

dim a,b,c
a = Cdbl(Major)
b = Cdbl(Minor)
c = Cdbl(Height)

Dim gr : Set gr = tcDraw.Graphics.Add(18,"SURFACE")
Dim gSurf : Set gSurf = gr.Surface
Dim Nods, Facts
Set Nods = gSurf.Nodes
dim numr,numc
' # variable for number of columns and rows so they can be easily adjusted
numr = 9
numc = 36
' # calculate angle intervals
dim vcen,ucen
vcen = Radians(90/numr)
ucen = Radians(360/numc)

'# Define the nodes
Dim i,j,U,V,x,y,z
'# use parametric equation to calculate the nodes and add them to the graphics node collection
For i = 0 to numr
V = i * vcen
   z = c*cos(V)

                       For j = 0 to numc
U = j*ucen
x = a*sin(V)*cos(U)
y = b*sin(V)*sin(U)
Nods.Add x,y,z
             Next
Next
 
Dim Nodelist(3)
 ' # Next we generate facets from sets of nodes.
       ' # expects an array of integers - index of the node in the graphics
       ' # node collection on a vertex of the facet
 
 Set facts = gSurf.Facets
Dim k , L
 
        For i = 0 To numr - 1
          k = (numc+1) * i                 ' # first index of each row
        For j = 0 to numc - 1
           L = k + j
            '# add 4 nodes for each facet
           nodelist(0) = L
            nodelist(1) = L + numc + 1
            nodelist(2) = L + numc + 2
            nodelist(3) = L + 1
            facts.Add nodelist
     
          Next
 
        Next
 
 '# 2 for smesh, 0 for surface, 1 for solid
 gr.Properties.Item("Solid").Value = 2
 
 gr.update
 gr.Draw

 Dim Urec : Set Urec = tcDraw.AddUndoRecord("Ellipsoid Hemisphere")
 Urec.AddGraphic gr
 Urec.Close

 tcDraw.ActiveView.Refresh

Set Urec = Nothing
Set Nods = Nothing
Set gSurf = Nothing
Set Facts = Nothing
Set gr = Nothing

End Sub
'__________________________________________________________________________________________________'
Function Radians(Degrees)
 Dim pi
 pi = 3.1415926535897932384626433832795
 Radians = Degrees * pi / 180
     
 End Function



Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

murray dickinson

That's impressive Nikki, but I suggested the relationship to DesignCAD's tools because they're graphical.  Being able to sketch 2D and 3D profiles and loft meshes with parametric resolution, or to use sections through triangular meshes and combinations of sketch and sections, with the different connection types between them is sublime, unlike my ability with maths.  They also permit local and differential subdivision, level of detail, with interpolated smoothing more simply and obviously than mathematically.  Another advantage for certain uses is that, exported as .dxf files, they open in TC and some other apps recognised specifically as AC 3D Polygon mesh entities, quad meshes with access to coordinate tables, which can be used to script other surface types in some other apps. 

nikkipollard

Sorry I was in a bit of a hurry this morning. The reason I looked into this originally , was that I wanted a way to create ruled surfaces - similar to some of sketch up's extensions.

My maths is not that great either, polynomials scare me.
But it is possible to write a script, that can read the vertices of Turbocad graphics. Interpolate them  (or whatever you need) and generate a triangulated surface from that. I will try to find the script I was playing with.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

murray dickinson

I'll see your intimidation by polynomials and raise you my FUD with scripts...   PunchCAD and FreeCAD have explicit ruled surface settings, they make unfolding/development a certainty, even between curve profiles.  Both of them will only accept two profiles to rule a surface between, but they can be 3D profiles.  TC does do ruled surfaces with the prism tool, but only between two profiles with matching node counts, which must use a very old algorithm, recent TC and other ACIS programs don't have the same limitation on lofting.  TC Prism's profiles have to be 2D, too.