Gestione figure parametriche

This commit is contained in:
Nicola Pievani
2025-02-24 09:27:03 +01:00
parent d6bf10959d
commit fc30fd5fa1
+41 -17
View File
@@ -18,6 +18,8 @@ PAR.dU1 = 0.0
PAR.nId2 = -1
PAR.Pt2 = Point3d(0,0,0)
PAR.dU2 = 0.0
PAR.nSubCrv1 = 0
PAR.nSubCrv2 = 0
PAR.Len = 0.0
@@ -78,7 +80,7 @@ end
--
local function EraseLinearDimension()
local IdDimension = EgtGetInfo( PAR.nId1, 'LinearDim', 'i')
local IdDimension = EgtGetInfo( PAR.nId1, 'LinearDim'..tostring(PAR.nSubCrv1), 'i')
EgtErase( IdDimension)
end
--
@@ -87,21 +89,41 @@ function PAR.DrawLinearDimension()
EraseLinearDimension()
local vtDir = EgtSV( PAR.nId1, GDB_RT.GLOB)
vtDir:rotate({0,0,1}, 90)
local IdDimension = EgtAlignedDimension( EgtGetParent(PAR.nId1),EgtSP( PAR.nId1, GDB_RT.GLOB), EgtEP( PAR.nId1, GDB_RT.GLOB),vtDir * 50,'<>',GDB_RT.GLOB)
EgtSetInfo( PAR.nId1, 'LinearDim', IdDimension)
local ptStart = EgtUP( PAR.nId1, PAR.nSubCrv1, GDB_RT.GLOB)
local ptEnd = EgtUP( PAR.nId1, (PAR.dU1 == PAR.nSubCrv1 and PAR.nSubCrv1 + 1 or PAR.dU1), GDB_RT.GLOB)
local IdDimension = EgtAlignedDimension( EgtGetParent(PAR.nId1), ptStart, ptEnd,vtDir * 50,'<>',GDB_RT.GLOB)
EgtSetInfo( PAR.nId1, 'LinearDim'..tostring(PAR.nSubCrv1), IdDimension)
ErasePoint( PAR.nId1)
EgtDraw()
end
--
function PAR.LiearDimension()
function PAR.LinearDimension()
if PAR.nId1 == -1 then return end
local dStartLen = EgtCurveLength( PAR.nId1)
local vsLen = PAR.Len
local vtDir = EgtSV( PAR.nId1, GDB_RT.GLOB)
local dFinalLen = tonumber( PAR.Len )
vtDir = vtDir * ( dFinalLen - dStartLen)
local NewEndPoint = EgtEP( PAR.nId1, GDB_RT.GLOB) + vtDir
EgtModifyCurveEndPoint( PAR.nId1, NewEndPoint, GDB_RT.GLOB)
if PAR.dU1 == PAR.nSubCrv1 then
local vtDir = EgtUV( PAR.nId1, PAR.nSubCrv1+0.1, GDB_RT.GLOB)
local dStartLen = dist(EgtUP( PAR.nId1, PAR.dU1, GDB_RT.GLOB), EgtUP( PAR.nId1, PAR.dU1 + 1, GDB_RT.GLOB))
vtDir = vtDir * ( dFinalLen - dStartLen) * (-1)
local NewStartPoint = EgtUP( PAR.nId1, PAR.dU1, GDB_RT.GLOB) + vtDir
if not (EgtGetType(PAR.nId1) == GDB_TY.CRV_COMPO) then
EgtModifyCurveStartPoint( PAR.nId1, NewStartPoint, GDB_RT.GLOB)
else
EgtModifyCurveCompoJoint( PAR.nId1, PAR.dU1, NewStartPoint, GDB_RT.GLOB)
end
else
local vtDir = EgtUV( PAR.nId1, PAR.nSubCrv1+0.1, GDB_RT.GLOB)
local dStartLen = dist(EgtUP( PAR.nId1, PAR.dU1, GDB_RT.GLOB), EgtUP( PAR.nId1, PAR.nSubCrv1, GDB_RT.GLOB))
vtDir = vtDir * ( dFinalLen - dStartLen)
local NewEndPoint = EgtUP( PAR.nId1, PAR.dU1, GDB_RT.GLOB) + vtDir
if not (EgtGetType(PAR.nId1) == GDB_TY.CRV_COMPO) then
EgtModifyCurveEndPoint( PAR.nId1, NewEndPoint, GDB_RT.GLOB)
else
EgtModifyCurveCompoJoint( PAR.nId1, PAR.dU1, NewEndPoint, GDB_RT.GLOB)
end
end
end
--
@@ -125,15 +147,15 @@ end
--
function PAR.AngularDimension()
local vtDir = EgtSV( PAR.nId1, GDB_RT.GLOB)
local vtDir1 = Vector3d(1,0,0)
local vtDir = EgtUV( PAR.nId1, PAR.nSubCrv1+0.1, GDB_RT.GLOB)
if PAR.nId2 then
vtDir1 = EgtSV( PAR.nId2, GDB_RT.GLOB) * (-1)
end
local dStartAng = math.acos( vtDir*vtDir1) * 180 / math.pi
local vsAng = PAR.Ang
vtDir1 = EgtSV( PAR.nId2, GDB_RT.GLOB)
end
local dStartAng = GetRotation(vtDir, vtDir1, Z_AX())
local vsAng = PAR.Ang
local dFinalAng = tonumber( vsAng)
EgtRotate({PAR.nId1},EgtSP(PAR.nId1, GDB_RT.GLOB),{0,0,1}, math.abs(dFinalAng-dStartAng),GDB_RT.GLOB)
local ptAx = EgtUP(PAR.nId1, PAR.dU1, GDB_RT.GLOB)
EgtRotate({PAR.nId1},ptAx,Z_AX(), math.abs(dFinalAng-dStartAng),GDB_RT.GLOB)
end
function PAR.Reset()
@@ -145,6 +167,8 @@ function PAR.Reset()
PAR.nId2 = -1
PAR.Pt2 = Point3d(0,0,0)
PAR.dU2 = 0.0
PAR.nSubCrv1 = 0
PAR.nSubCrv2 = 0
end
--