[VB.Net] API Solidworks Thread-editie

Hallo

 

Hoe hard ik ook kijk, ik kan geen enkele manier vinden om alleen de afmetingen van een draad in solidworks te bewerken

 

Scenario

Bestaand onderdeel met M10 schroefdraad

Objectief

Verander de M10 naar M12 zonder het geven van de diepte info of iets anders zo gebaseerd net alsof de gebruiker veranderen in de solidworks dialoog

 

Ik keek naar HoleWizard, maar het is alleen om de draad te maken en niet om het te bewerken :/

Ik heb de zijne gevonden

http://help.solidworks.com/2015/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IWizardHoleFeatureData2~ChangeStandard.html

Maar ik zie niet hoe ik mijn functie van tevoren moet selecteren :/

Hallo

 

Wil je een 2D tekening in 3D bewerken?

 

In het onderdeelbestand direct ;)

Met behulp van ondersteuning is hier de code die werkt onder VB.net

Dim File As String = "C:\Test.SLDPRT"
Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(File)
swDocSpecification.Silent = True : swDocSpecification.ReadOnly = False : swApp.OpenDoc7(swDocSpecification)
Dim Part As PartDoc = swApp.ActiveDoc
Dim swModel As SldWorks.ModelDoc2 = swApp.ActiveDoc
Dim featMgr As FeatureManager = Part.FeatureManager
'
Dim swSelMgr As SldWorks.SelectionMgr = swModel.SelectionManager
swModel.Extension.SelectByID2("Schroefdraadgat ", "BODYFEATURE"000False0Nothing0)
Dim swFeat As SldWorks.Feature = swSelMgr.GetSelectedObject6(1, -1)
Dim instantie As IWizardHoleFeatureData2
Dim Standard As Int32 = 8
Dim FastenerType As Int32 = 147
Dim SSize As String = "M30"
instantie = swFeat.GetDefinition-instantie
. ChangeStandard(Standard, FastenerType, SSize)
swFeat.ModifyDefinition(instance, swModel, Nothing)
'
Part.ForceRebuild() 'Reconstruction
Dim fileerror, filewarning As Integer
Dim boolstatus As Boolean = swModel.Save3(SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent, fileerror, filewarning) 'Wijzigingen opslaan swApp.CloseDoc (Bestand) 'De kamer sluiten    

Met behulp van ondersteuning is hier de code die werkt onder VB.net

Dim File As String = "C:\Test.SLDPRT"Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(File) swDocSpecification.Silent = True : swDocSpecification.ReadOnly = False : swApp.OpenDoc7(swDocSpecification)Dim Part As PartDoc = swApp.ActiveDocDim swModel As SldWorks.ModelDoc2 =      swApp.ActiveDocDim featMgr As FeatureManager = Part.FeatureManager 'Dim swSelMgr As SldWorks.SelectionMgr = swModel.SelectionManager swModel.Extension.SelectByID2("Threaded Hole", "BODYFEATURE", 0, 0, 0,  False, 0, Nothing, 0)Dim swFeat As SldWorks.Feature = swSelMgr.GetSelectedObject6(1,  -1)Dim instance As IWizardHoleFeatureData2 Dim Standard As Int32 = 8Dim FastenerType As Int32 = 147 Dim SSize As String = "M30"instance = swFeat.GetDefinition instantie. ChangeStandard(Standard, FastenerType, SSize) swFeat.ModifyDefinition(instance, swModel, Nothing) 'Part.ForceRebuild() 'Reconstruction Dim fileerror, filewarning As IntegerDim boolstatus As Boolean = swModel.Save3(SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent, fileerror, filewarning) 'Saving  ChangeswApp.CloseDoc( Bestand) 'De kamer sluiten   

Zou het mogelijk zijn om de VBA-code van de volledige macro in een txt-bestand te zetten als bijlage bij een reactie? Want hier is het een beetje onleesbaar...