Umieszczanie ograniczenia w usuniętym stanie API

Witam

Już fajne ulepszenie forum, widzę, że ewoluuje tutaj w dobrym kierunku!

Mam prośbę od kolegi, który chce, abym poprawił moje makro, które pozwala mi wstawić komponent, " wydany " umieścić zbieżność początk/punkt i go naprawić.

Problem w niektórych przypadkach musimy zmienić pozycję, więc aby ułatwić sobie życie i zyskać kilka " kliknięć ", prosi mnie o wprowadzenie stanu usunięcia ograniczenia przed naprawieniem mojej części.

Zrobiłem wiele badań i automatycznego nagrywania makr, ale nic nie wyszło. Nie mogę wybrać ograniczenia ani umieścić ograniczenia w stanie usuniętym

'suppression du "Fixe" sur la première pièce
boolstatus = swModel.Extension.SelectByID2(CompInsert, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
swModel.UnfixComponent

'Selection du composant et ajout contrainte coincident origine/origine
swModel.ClearSelection2 True
boolstatus = swModel.Extension.SelectByID2(FirstSelection, "EXTSKETCHPOINT", 0, 0, 0, False, 1, Nothing, 0)
boolstatus = swModel.Extension.SelectByID2(SecondSelection, "COORDSYS", 0, 0, 0, True, 1, Nothing, 0)
Set swMate = swModel.AddMate5(20, -1, False, 0, 0.001, 0.001, 0.001, 0.001, 0.5235987755983, 0.5235987755983, 0.5235987755983, False, False, 0, longstatus)

'Remettre la pièce "Fixe"
boolstatus = swModel.Extension.SelectByID2(CompInsert, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
swModel.FixComponent
swModel.ClearSelection2 True

W oczekiwaniu na Wasze odpowiedzi życzę wszystkim wesołych świąt.

Witam @mandragore
Myślę, że będę musiał przejść przez drzewo i zdobyć odpowiednią funkcję

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swAssembly As AssemblyDoc
Dim swswSelmgr As SelectionMgr
Dim swFeature As Feature
Dim swMate As Mate2
Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swAssembly = swModel
Set swSelmgr = swModel.SelectionManager
Dim swError As Long
Set swMate = swAssembly.AddMate5(swMateType_e.swMateCOINCIDENT, swMateAlign_e.swAlignNONE, False, 0, 0, 0, 0, 0, 0, 0, 0, False, False, 0, swError)
swModel.ForceRebuild3 True
Set swFeature = GET_MATE_FEATURE()
swFeature.SetSuppression2 swFeatureSuppressionAction_e.swSuppressFeature, swInConfigurationOpts_e.swThisConfiguration, Nothing
End Sub

Function GET_MATE_FEATURE() As Feature
    Dim curentFeature As Feature
    Set curentFeature = swModel.FirstFeature
    Dim lastFeature As Feature
    Do While Not curentFeature Is Nothing
    If curentFeature.GetTypeName2() = "MateGroup" Then
        Dim subFeature As Feature
        Set subFeature = curentFeature.GetFirstSubFeature
        Set lastFeature = subFeature
        Do While Not subFeature Is Nothing
            Set lastFeature = subFeature
            Set subFeature = subFeature.GetNextSubFeature
        Loop
        Exit Do
    End If
    Set curentFeature = curentFeature.GetNextFeature()
    Loop
    Set GET_MATE_FEATURE = lastFeature
End Function

2 polubienia

Od wersji 2019 funkcja Createmate pozwala również na tworzenie standardowych ograniczeń i zwraca cechę bezpośrednio,

2 polubienia