標籤:
Public Sub CycleObjects(ByVal view As NXOpen.Tag, ByVal type As NXOpen.UF.UFView.CycleObjectsEnum, ByRef _object As NXOpen.Tag) NXOpen.UF.UFView 的成員
在指定視圖中迴圈對象
1.如果視圖(view)為NULL_TAG(.NET:NXOpen.Tag.Null),則使用工作視圖。
2.type=UF_VIEW_VISIBLE_OBJECTS(.NET:NXOpen.UF.UFView.CycleObjectsEnum.VisibleObjects),返回視圖矩形邊界內的所有可見對象;不會返回跨越邊界或在邊界外的對象。不支援製圖成員的非矩形邊界,如果想擷取製圖成員的非矩形邊界視圖的可見對象,或跨越視圖邊界的對象,請使用UF_VIEW_ask_visible_objects。
3.在結束遍曆迴圈之前,不能刪除或者擦除對象,不能通過添加或移除視圖進行邊界。如果需要刪除遍曆尋找的對象,請建立一個數組,在遍曆結束以後,對對象數組進行刪除操作。
PS:這個功能將會返回用於顯示的實體輪廓邊緣(包括面和邊)。在使用者定義圖層(1~256層)中。
個人的理解是:
type=UF_VIEW_VISIBLE_OBJECTS,返回視圖邊界內的可見對象,包括實體輪廓。
type=UF_VIEW_DEPENDENT_OBJECTS ,返回視圖內的可以顯示的製圖對象(包括隱藏但可以顯示的製圖對象),不包括不能顯示的對象,不包括實體輪廓。
type=UF_VIEW_ERASED_OBJECTS,
type=UF_VIEW_MODIFIED_OBJECTS ,
下面的代碼,是擷取在工作視圖可以顯示的40層裡的注釋。
Dim theSession = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim theUfSession = UFSession.GetUFSession() Dim lw = theSession.ListingWindow lw.Open Dim _object = NXOpen.Tag.Null Do theUfSession.View.CycleObjects(NXOpen.Tag.Null, NXOpen.UF.UFView.CycleObjectsEnum.DependentObjects, _object) If _object = NXOpen.Tag.Null Then Exit Do Else Dim _type, _subtype As Integer theUfSession.Obj.AskTypeAndSubtype(_object, _type, _subtype) ‘lw.WriteLine(String.Format("Type:{0} Subtype:{1}", _type, _subtype)) If _type = UFConstants.UF_drafting_entity_type AndAlso _subtype = UFConstants.UF_draft_note_subtype Then Dim note1 As Annotations.Note = TryCast(Utilities.NXObjectManager.Get(_object), Annotations.Note) If note1 IsNot Nothing Then If note1.Layer = 40 Then ‘TODO:位於40層的注釋 ‘theSession.Information.DisplayObjectsDetails({note1}) End If End If End If End If Loop While _object <> NXOpen.Tag.Null
NXOpen.UF.UFView.CycleObjects 的使用