==================
The AcGe class library is a tool class library provided for the AcDb class library, such as vector objects and matrix objects for two-dimensional and three-dimensional operations. In addition, many basic geometric objects are provided, such as points, curves, and surfaces.
The AcGe class library mainly contains two sub-sets: classes for two-dimensional calculations and classes for three-dimensional calculations. The main base classes are AcGeEntity2d and AcGeEntity3d. There are also several classes without a base class, including AcGePoint2d, AcGeVector2d, and AcGeMaterix2d. These basic classes can be used to perform many types of common operations, such as point and vector operations, multiplication and cross-multiplication between vectors. Operations between matrices. Many implementations of these subclasses make use of the operations of these base classes.
==============
Let’s discuss how to get the overlapping part of two curves
There is a class AcGeCurveCurveInt3d in the geometry library. This class handles various positional relationships between two intersecting curves. Among them
1. The overlapCount method obtains the number of overlapping segments.
2. getOverLapRanges obtains the parameter (AcGeInterval) of the overlapping range on the two curves at the specified index (number, based on 0)
After getting the overlapping parameter range, you can deduct the local curve (using the xd::curve:getsub function of the general function library)
XDRX API encapsulates ARX's geometry library methods for LISP calls
===============
(defun XD::Curve:GetSub
(e p1 p2 testPnt
/ ge1 pa1 pa2 testpa
) ;(xdrx_getpropertyvalue e "isclosed")
(>= pa1 testpa)
(<= pa2 testpa)
)
)
(not (< pa1 testpnt pa2
)) )
(defun _trimEnts
(ge1 pa1 pa2
) (xdge::setpropertyvalue ge1 "setinterval" pa1 pa2)
ge1
)
(setq ge1
(xdge::constructor e
)) )
)
(setq pa1
(xdge::getpropertyvalue ge1
"paramof" p1
) pa2 (xdge::getpropertyvalue ge1 "paramof" p2)
testPa (xdge::getpropertyvalue ge1 "paramof" testPnt)
)
)
pa2 p2
)
)
)
)
'(pa1 pa2)
)
(setq ge1
(_trimEnts ge1 pa2 pa1
)) (setq ge1
(_trimEnts ge1 pa1 pa2
)) )
ge1
)
"\nSelect the first polyline<Exit>:"
'((0 . "LWPOLYLINE"))
)
)
)
"\nSelect second polyline <Exit>:"
'((0 . "LWPOLYLINE"))
)
)
)
)
(setq g1
(xdge::constructor e1
) ;;Construct the geometric entity of the first polyline g2 (xdge::constructor e2) ;;Construct the geometric entity of the second polyline
)
(if (setq gint
(xdge::constructor
"kCurveCurveInt3d" g1 g2
)) ;;Construct AcGeCurveCurveInt3d object from two geometric entities (setq num
(xdge::getpropertyvalue gint
"overlapcount")) ;;Get the number of overlapping segments )
g (xdge::getpropertyvalue gint "getOverLapRanges" i) ;;Get the overlapping curve range parameters of the i-th segment
intv1
(car g
) ;;Get the range AcGeInterval object of the overlapping part of the first curve param (xdge::getpropertyvalue intv1 "getbounds") ;;Get the upper and lower range of curve parameters from AcGeInterval
)
(setq e
(xd::curve:getsub e1
(car param
) (cadr param
) 0)) ;;Call the general LISP function library function to deduct part of the curve entity (geometric entity) (xdge::entity:make e) ;;Generate database AcDbPolyline object
(xdrx_setpropertyvalue;;Set color 6, constant width 60
"color"
6
"constantwidth"
60.0
)
)
(xdrx_prompt "\n" num "Overlapping segments found, marked in magenta.")
)
) (xdge::free)
)
)
)
=================
AcGeCurveCurveInt3d class, XDRXAPI encapsulated method
Typical process of generating overlapping segments:
1.
Construct the AcGe geometric object corresponding to curve 1.Command:(setq g1 (xdge::constructor (entlast)))
<图元名: 2a1fcf01610>
Command: (xdrx-object-isa g1)
"AcGe::kLineSeg3d"
2.
Construct the AcGe geometric object corresponding to curve 2.Command:(setq g2 (xdge::constructor (entlast)))
<图元名: 2aa0895d400>
Command: (xdrx-object-isa g2)
"AcGe::kLineSeg3d"
3.
Construct the AcGe geometric object corresponding to kCurveCurveInt3d where curve 1 and curve 2 intersect.Command: (setq gint (xdge::constructor "kCurveCurveInt3d" g1 g2))
<图元名: 2aa0895d8c0>
Command: (xdrx-object-isa gint)
"AcGe::kCurveCurveInt3d"
4.
Get the number of overlapping segments.Command: (setq num (xdge::getpropertyvalue gint "overlapcount"))
1
5.
Get the overlapping curve range parameters of the i-th segmentCommand: (setq g (xdge::getpropertyvalue gint "getOverLapRanges" 0))
(<图元名: 2aa0895cd20> <图元名: 2aa0895cf20>)
Command:(xdge::type (car g))
"AcGeInterval"
6.
Get the upper and lower range of curve parameters from AcGeIntervalCommand: (xdge::getpropertyvalue (car g) "getbounds")
(0.5 1.0)
7.
;The setintval method obtains the kLine3d geometric curveCommand: (setq gint (xdge::setpropertyvalue g1 "setinterval" (car param)(cadr param)))
<图元名: 2a1fcf01610>
Command:(xdge::type gint); AcGe::KLineSeg3d Object
"kLineSeg3d"
8.
;Generate the database AcDbLine object and obtain the curve entity of the overlapping segment.Command:(setq e (xdge::entity:make gint))
<图元名: 2a1d36c5dd0>
命令: (xdrx-object-isa e)
"AcDbLine"
If only the entity name is given as a parameter, the query and editing C++ methods that support this geometric object will be printed.Command: (xdge::getpropertyvalue gint)
<kCurveCurveInt3d>:
Edit Functions:
├───set
Intersection Query Functions:
├───intPoint
├───intPoints
├───intPointTol
├───isTangential
├───isTransversal
├───numIntPoints
├───overlapCount
├───overlapDirection
Ordering Functions:
├───changeCurveOrder
├───orderWrt1
├───orderWrt12
Query Functions:
├───curve1
├───curve2
├───getIntParams
├───getIntRanges
├───getOverlapRanges
├───getPointOnCurve1
├───getPointOnCurve2
├───tolerance
<kEntity3d>:
Equality Checking Functions:
├───isEqualTo
Point Containment Functions:
├───isOn
Type Identification Functions:
├───isKindOf
├───type
=======================
The above LISP code uses the XDRX-API, which can be downloaded from
https://github.com/xdcad/XDrx-APIThe XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.