Chuyển đến nội dung
Diễn đàn CADViet
Đăng nhập để thực hiện theo  
conghoangxd037

Tìm giao điểm các đối tượng trong Selectionset

Các bài được khuyến nghị

Giả sử tập chọn có n đối tượng

 

Dùng 2 vòng lặp lồng nhau, một cái chạy theo i = 1 .. n-1, cái kia chạy từ i+1 đến n để tránh trùng hợp.

Dùng hàm IntersectWith để tìm giao giữa 2 đối tượng.

 

IntersectWith Method

 

Gets the points where one object intersects another object in the drawing.

 

Signature

RetVal = object.IntersectWith(IntersectObject' date=' ExtendOption)

 

object: All Drawing Objects (Except Pviewport and PolygonMesh)

The object or objects this method applies to.

 

IntersectObject: Object, input-only;

The object can be one of All Drawing Objects.

 

ExtendOption: AcExtendOption enum; input-only

 

This option specifies if none, one or both, of the objects are to be extended in order to attempt an intersection.

acExtendNone

Does not extend either object.

acExtendThisEntity

Extends the base object.

acExtendOtherEntity

Extends the object passed as an argument.

acExtendBoth

Extends both objects.

 

RetVal

Variant (array of doubles)

The array of points where one object intersects another object in the drawing.

Remarks

If the two objects do not intersect, no data is returned. You can request the point of intersection that would occur if one or both of the objects were extended to meet the other. For example, in the following illustration, Line1 is the base object from which this method was called and line3 is the object passed as a parameter. If the ExtendOption passed is acExtendThisEntity, point A is returned as the point where line1 would intersect line3 if line1 were extended. If the ExtendOption is acExtendOtherEntity, no data is returned because even if line3 were extended, it would not intersect line1.

If the intersection type is acExtendBothEntities and line2 is passed as the parameter entity, point B is returned. If the ExtendOption is acExtendNone and line2 is the parameter entity, no data is returned.

 

More information:

http://www.progecad.us/index.pl?iid=21577

http://forums.autodesk.com/t5/Visual-Basic-Customization/intersectwith/td-p/1343013

  • Vote tăng 1

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

em tạo một topic mới nhưng lại bị mod xóa thì phải thui em đành nhờ topic này tạm vậy

em có một đoạn VBA sau

Sub a()

On Error Resume Next

Dim bbs As AcadSelectionSet

 

ThisDrawing.SelectionSets("bbs").Delete

Set bbs = ThisDrawing.SelectionSets.Add("bbs")

 

bbs.Select acSelectionSetAll

bbs.Select acSelectionSetAll

bbs.Select acSelectionSetAll

bbs.Select acSelectionSetAll

End Sub

trên là có 4 đoạn " bbs.Select acSelectionSetAll" giả sử trong đoạn mã của em mà có 100 đoạn thế thì khi thực hiện lệnh cái dòng command line của em nhảy 100 phát gây ức chế quá. em đã thử dùng "ThisDrawing.SetVariable "cmdecho", 0" mà vẫn ko ăn thua. bác nào có chiu nào chỉ giáo em với. Trong excel thì có "screenupdating" lisp thì có "Cmdecho" còn VBA for cad thì em tìm mãi chả thấy đâu cả cảm ơn các bác đã quan tâm.

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

Tạo một tài khoản hoặc đăng nhập để nhận xét

Bạn cần phải là một thành viên để lại một bình luận

Tạo tài khoản

Đăng ký một tài khoản mới trong cộng đồng của chúng tôi. Điều đó dễ mà.

Đăng ký tài khoản mới

Đăng nhập

Bạn có sẵn sàng để tạo một tài khoản ? Đăng nhập tại đây.

Đăng nhập ngay
Đăng nhập để thực hiện theo  

×