Hello everyone
Using "GetSketchSegment" in a macro we can get all sketch elements, but in a sketch of a revolve feature, is it possible to know which one of these segments is used as an axis for this revolve feature?
Thanks
Hello everyone
Using "GetSketchSegment" in a macro we can get all sketch elements, but in a sketch of a revolve feature, is it possible to know which one of these segments is used as an axis for this revolve feature?
Thanks
According to the API documentation, the segment should be set with a mark to 16. I don't remember if that value is only set during selection or if it's permanently attached to the segment. I hope this points you in the right direction.
2016 SOLIDWORKS API Help - FeatureRevolve2 Method (IFeatureManager) - see the Remarks section
Hello, try this.
It will select the segment used for the selected revolve feature
Adapted from 2018 SOLIDWORKS API Help - Get Axis of Revolve Feature Example (VBA)
Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSelMgr As SldWorks.SelectionMgr Dim featdata As SldWorks.RevolveFeatureData2 Dim feat As SldWorks.Feature Dim skobj As SldWorks.SketchSegment Dim edgeobj As SldWorks.Entity Dim axisobj As SldWorks.RefAxis Dim boolstatus As Boolean Dim longstatus As Long Dim swSketch As SldWorks.Sketch Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set feat = swSelMgr.GetSelectedObject5(1) Set featdata = feat.GetDefinition boolstatus = featdata.AccessSelections(swModel, Nothing) longstatus = featdata.GetAxisType Set skobj = featdata.Axis Select Case longstatus Case SwConst.swSelSKETCHSEGS Set skobj = featdata.Axis featdata.ReleaseSelectionAccess Set swSketch = skobj.GetSketch boolstatus = swSketch.Select4(False, Nothing) swModel.EditSketch boolstatus = skobj.Select4(False, Nothing) Case SwConst.swSelDATUMAXES Set axisobj = featdata.Axis Set feat = axisobj boolstatus = feat.Select2(False, 0) Case SwConst.swSelEDGES Set edgeobj = featdata.Axis boolstatus = edgeobj.Select4(False, Nothing) End Select featdata.ReleaseSelectionAccess End Sub
I really want to thank you all for your kind responses. It is a shame I can not mark more than one answer as the correct answer, because you all have really helped me.
But I have to say that Rob Edwards'sanswer is actually right into heart of the target, so I am going to mark it as the correct answer, BUT, I am really grateful for all of you gentle men (or ladies, where appropriate ).
Hi Emad
Maybe this helps
2017 SOLIDWORKS API Help - Get Axis of Revolve Feature Example (VBA)