Script : MovePointOnPlane

[BLOCKQUOTE class=’ip-ubbcode-quote’][div class=’ip-ubbcode-quote-title’]quote:[/div][div class=’ip-ubbcode-quote-content’]Originally posted by Amabilis Support:
To move a point along an edge hold down the E and Z keys, click on a point and drag (left right). [/div][/BLOCKQUOTE]
Thanks for the reply.

I didn’t know this feature.
This is really useful : when dividing an edge, the points are evenly distributed along the edge. With the E/Z trick, it is possible to have a point elsewhere (I would have used this function before if I knew it existed).

[b:1pdhxpxm]Whatever you have in mind about moving a point along a plane, don’t change the E/Z trick.[/b:1pdhxpxm]

Btw, my script is not about moving a point along a plane but projecting it on a plane.

This script moves a point in the same plane made by 3 points.
[pre class=’ip-ubbcode-code-pre’]
Language = VBScript

‘ Purpose: Move a point on the same plane as 3 selected points

Option Explicit ‘require variable declarations

Sub Main (3DCApp)

Dim GeneralMessage
Dim Message
Dim Scene
Dim Object
Dim X1, Y1, Z1
Dim X2, Y2, Z2
Dim X3, Y3, Z3
Dim Xa, Ya, Za
Dim Xp, Yp, Zp
Dim Ap, Bp, Cp, Dp
Dim i
Dim PointDistance
Dim ActivePointsCount
Dim ActiveObjectsCount
Dim CurrentPoint, PointP

GeneralMessage=’Please select the point to be projected on a plane followed by 3 different points making up the plane’

‘get the scene
Set Scene = 3DCApp.GetActiveScene

‘Count number of selected points
ActiveObjectsCount = Scene.GetActiveObjectCount
ActivePointsCount = Scene.GetActivePointCount

‘only proceed if there are 4 active points
If ActivePointsCount andlt;andgt; 4 AND ActiveObjectsCount andlt;andgt; 4 Then
MsgBox GeneralMessage
Set Object = Scene.GetActiveObject(0)

‘ Get the point to be projected
PointP = Scene.GetActivePoint(0)
Object.GetPoint PointP, Xa, Ya, Za

‘ Get first point
CurrentPoint = Scene.GetActivePoint(1)
Object.GetPoint CurrentPoint, X1, Y1, Z1

‘ Get second point
CurrentPoint = Scene.GetActivePoint(2)
Object.GetPoint CurrentPoint, X2, Y2, Z2

‘ Get third point
CurrentPoint = Scene.GetActivePoint(3)
Object.GetPoint CurrentPoint, X3, Y3, Z3

‘ Checks in case of welded points selection
If X1=X2 AND Y1=Y2 AND Z1=Z2 Then
Message=GeneralMessageand’ (Plane points 1 and 2 are identical)’
If X1=X3 AND Y1=Y3 AND Z1=Z3 Then
Message=GeneralMessageand’ (Plane points 1 and 3 are identical)’
If X2=X3 AND Y2=Y3 AND Z2=Z3 Then
Message=GeneralMessageand’ (Plane points 2 and 3 are identical)’
Message=’Plane points: ‘andX1and’ ‘andY1and’ ‘andZ1and’ // ‘andX2and’ ‘andY2and’ ‘andZ2and’ // ‘andX3and’ ‘andY3and’ ‘andZ3
Message=Messageand’ Point to be projected ‘andXaand’ ‘andYaand’ ‘andZa

‘ Compute plane parameters
Ap = (Y2 – Y1)*(Z3 – Z1) – (Z2 – Z1)*(Y3 – Y1)
Bp = -(X2 – X1)*(Z3 – Z1) + (Z2 – Z1)*(X3 – X1)
Cp = (X2 – X1)*(Y3 – Y1) – (Y2 – Y1)*(X3 – X1)
i = SQR(Ap^2+Bp^2+Cp^2)
‘ Normalize
Dp = -Ap*X1 – Bp*Y1 – Cp*Z1
‘ Distance from plane
PointDistance = Ap*Xa+Bp*Ya+Cp*Za+Dp
‘Compute the new coordinates

‘Message=’A=’andApand’ B=’andBpand’ C=’andCpand’ D=‘andDpand’ PointDistance=’andPointDistanceand’ Projection=’andXpand’ ‘andYpand’ ‘andZp

‘ Set new coordinates
Object.SetPoint PointP, Xp, Yp, Zp

‘ Finally write a Script operation layer to save the change
End IF
End IF
End If
End If
End Sub

Thanks in advance for clarifying a few points:

1) Is it possible to select the points in 2 steps instead of one: 3 selected points are used at the beginning of the script and then the user is asked to select the point to project? From the little I know of 3DC scripting, it doesn’t seem possible.
2) Is it possible to select points from different objects? As it is the script can only work on points of the same object.
3) I wanted to make a variation of the script replacing the plane making up the plane by a face. However, I don’t see a way of selecting a point and a face before the script execution. It could be done if the answer is yes to point 1.

Unfortunately, ‘no’ is the answer to all three questions.

The goal is to move the point along a selected plane? A very handy feature. 3DC has a function for moving a point along an edge, but not a plane. Well… I believe I originally intended it to move a point along a plane. It doesn’t seem to do that unfortunately. I’ll fix it. Just give me time. <!– s:) –><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!– s:) –>

To move a point along an edge hold down the E and Z keys, click on a point and drag (left right). It only really works on a point along a divided edge (a point shared by only two faces).

I really should improve this since it is really handy. It’s on my list.

You must be logged in to reply in this thread.

3 posts
recent posts