Is there any way to access Start/End Constraints parameters (shown in the picture) for different kinds of tangency through a VBA macro? Use Solidworks 2011 API.
Could not find it among CreateLoftSurface method parameters.
Any tips or pointers?
Your screenshot corresponds to the call IFeatureManager.InsertProtrusionBlend2 which contains all the tangency options you are looking for.
2011 SOLIDWORKS API Help - InsertProtrusionBlend2 Method (IFeatureManager)
Thank you for your relpy.
IFeatureManager.InsertProtrusionBlend2 is called to create a body, but I need to create a surface.
It seems, the screenshot doesn'texactly correspond to the description..
Taking into account InsertProtrusionBlend2 method parameters I need properties called StartTangentLength and EndTangentialLength. I wonder if it's possible to set them after creation of the surface with ILoftFeatureData Interface or something?
The surface equivalent is 2011 SOLIDWORKS API Help - InsertLoftRefSurface2 Method (IModelDoc2)
The CreateLoftSurface method you mentioned is for creating a temporary body, which will not have a corresponding ILoftFeatureData object. The InsertLoftRefSurface2 should do the job for you.
EDIT: you may be right that after calling that method, get the feature and use GetSpecificFeature to retrieve the ILoftFeatureData object. That should give you access to the start and end options.
It seems the approach with ILoftFeatureData doesn't work here.
My code tries to access the parameter on a selected loft surface but it says:
"Run-time error '91' Object variable or With block variable not set".
However, if I make it access a 'real' loft body, it prints out StartTangentLength value just fine.
Dim swApp As SldWorks.SldWorks
Dim Model As SldWorks.ModelDoc2
Dim boolstatus As Variant
Dim swFeat As SldWorks.feature
Dim swFeatData As SldWorks.LoftFeatureData
Set swApp = Application.SldWorks
Set Model = swApp.ActiveDoc
' Select the feature named "Extrude1"
boolstatus = Model.Extension.SelectByID2("Extrude1", "REFSURFACE", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
If boolstatus = True Then
Dim SelMgr As SelectionMgr
Set SelMgr = Model.SelectionManager
Set swFeat = SelMgr.GetSelectedObject6(1, 0)
Set swFeatData = swFeat.GetDefinition
Debug.Print "StartTangentLength=" & swFeatData.StartTangentLength 'Error message
Else Debug.Print "Error"End If
Looks like it's a limitation in Feature.GetDefinition.
According to the documentation, "BlendRefSurface" returns Nothing for a Surface-Loft feature.
Maybe you could try a boundary suface instead?
Unfortunately the Boundary surface is too different to fit - there are no control values such as StartTangentLength.
Retrieving data ...