maksolino 发表于 2022-7-6 14:54:48

intersect spline whith z-coord

i'm looking for a lisp routine for intersect spline atcoordinate value
   example
1. select the splines
2. input value of coordinate   (x=200 or y=400 or z=1000)
result points indrawing
Thank you

maksolino 发表于 2022-7-6 14:59:47

i must add that the spline is always perpendicular on
some axis (in this case its about ship frames and water lines).
Im not at home whith lisp programming but the way to do it can be
1.input value (like z=4000)
1.when select a string ittakes a position of the axis
2. draw a perpendicolar line on the axis whit value -100000 +100000
2. find a intersection point between line and spline
3. delete the line
4.draw the point

SEANT 发表于 2022-7-6 15:02:23

Unfortunately, I don’t know lisp.I did set up a test VBA routine.It only works with one orientation, however, with a target elevation along the Z axis.
 
The routine works best from either a Front or Side view – and a point picked at the desired intersection plane.
 
*Correction: Only works with entities parallel to the Front view* not Side View
 
Limited error checking employed.
 

Sub PointsAtElevation()Dim dblPt(2) As DoubleDim ent As AcadEntityDim entMirror As AcadEntityDim varMin As VariantDim varMax As VariantDim dblThird(2) As DoubleDim dblElevation As DoubleDim varElevPt As VariantDim varReturn As VariantDim intCount As IntegerDim i As IntegerDim entPt As AcadPointDim objSS As AcadSelectionSetWith ThisDrawingOn Error Resume Next.SelectionSets.Item("SSTemp").DeleteOn Error GoTo 0Set objSS = .SelectionSets.Add("SSTemp")objSS.SelectOnScreenIf objSS.Count < 1 Then Exit SubvarElevPt = .Utility.GetPoint(, "Select target elevation: ")If UBound(varElevPt)2 Then Exit SubFor Each ent In objSS   ent.GetBoundingBox varMin, varMax   varMin(2) = varElevPt(2)   varMax(2) = varElevPt(2)   dblThird(0) = varMin(0)   dblThird(1) = varMin(1) + 1#   dblThird(2) = varMin(2) + 1#   Set entMirror = ent.Mirror3D(varMin, varMax, dblThird)   varReturn = entMirror.IntersectWith(ent, acExtendNone)   intCount = ((UBound(varReturn) + 1) / 3) - 1   For i = 0 To intCount      dblPt(0) = varReturn(3 * i)      dblPt(1) = varReturn(3 * i + 1)      dblPt(2) = varReturn(3 * i + 2)      ThisDrawing.ModelSpace.AddPoint (dblPt)   Next   entMirror.DeleteNextEnd WithEnd Sub

SEANT 发表于 2022-7-6 15:04:59

I should point out that I'm assuming the Splines are all planar and in parallel planes.

David Bethel 发表于 2022-7-6 15:08:52

I'd say that it could not be done with plain AutoLISP.I guess my question would be how to deal with multiple intersections of the spline with the given plane.I would think that a full ship frame intersects say the water line in 2 places.-David

SEANT 发表于 2022-7-6 15:12:37

 
No doubt.
 

Perhaps even more if the design is a tunnel hull, cat- or trimaran.

maksolino 发表于 2022-7-6 15:14:29

Fisrt thank you for the answer but my exsperience whith vba is very poor
and i am not good enough to use the code.
Second i wont to add that always we divide the body lines of the ship
in left side, right side(almost mirror of left side),fore part and aft part.
In this case there is no multiple intersections of the spline.
Can somebody make the whole vba or lisp routine ?
Greetings

SEANT 发表于 2022-7-6 15:19:53

Is it possible to post a sample file with the splines set up in a typical configuration?I’m envisioning a oriented 3D layout but guess I don’t know that for certain.
 
In general, an example file is the best way to give full scope to the problem in question.The “full scope” also seems to be the best way to generate interest and enthusiasm within in the resident code writing community.

maksolino 发表于 2022-7-6 15:23:20

sorry that i don't do it before
naw i attach one sample file with the splines set up in a typical configuration.
I must draw a lot of waterlines and then a lot of frames
Frames is in always situated in yz plane
and waterlines in xy plane
testforma.dwg

Lee Mac 发表于 2022-7-6 15:24:17

This is probably way off, as I have only caught the end of this thread, but this should find the intersections between your spline and the Polylines.
 

(defun c:SplInt (/ spEnt ss spObj ObjLst iArr ptLst) (if (and (setq spEnt (car (entsel "\nSelect Spline to Retrieve Intersections...")))      (= "SPLINE" (cdadr (entget spEnt)))      (setq ss (ssget "X" (list (cons 0 "LWPOLYLINE") (cons 8 "SHP")         (if (getvar "CTAB")(cons 410 (getvar "CTAB"))               (cons 67 (- 1 (getvar "TILEMODE"))))))))   (progn   (setq spObj (vlax-ename->vla-object spEnt)       ObjLst (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))   (foreach Obj ObjLst   (setq iArr (vlax-variant-value (vla-IntersectWith spObj Obj acExtendNone)))   (if (> (vlax-safearray-get-u-bound iArr 1) 0)       (setq ptLst (cons (vlax-safearray->list iArr) ptLst))))   (alert (vl-princ-to-string ptLst)))   (princ "\n No Spline Selected or No PLines Found ")) (princ))
页: [1] 2
查看完整版本: intersect spline whith z-coord