Harold Black

Library definition not updating properly

Discussion created by Harold Black on Jan 2, 2020
Latest reply on Jan 5, 2020 by Harold Black

I'm trying to insert a pre-made library feature. I followed the code given in this example here. The location point is where the library feature will be placed. The problem that I am encountering is that my library definition does not see the endpoint I selected for the Up To Vertex. The AxisPt1 is not being selected for the definition update.

 

Set swLibFeat = swFeatMgr.CreateDefinition(swFeatureNameID_e.swFmLibraryFeature)
swLibFeat.Initialize "C:\ProgramData\SolidWorks\SOLIDWORKS 2019\Design Library\test\Boss-Extrude2.SLDLFP"

swLibFeat.ConfigurationName = "Default<As Machined>"
swLibFeat.LinkToLibraryPart = False
swLibFeat.OverrideDimension = False

AxisPt2.Select True   'location of library feature

Set swFeat = swFeatMgr.CreateFeature(swLibFeat)

Set swLibFeat = Nothing
Set swLibFeat = swFeat.GetDefinition
bool = swLibFeat.AccessSelections(swModel, Nothing)

AxisPt2.Select True
skFeatureAxis.Select True   'direction of library feature
skAlignVector.Select True   'orientation of library feature
AxisPt1.Select True   'ending of library feature

Dim selCount As Long
selCount = swSelMgr.GetSelectedObjectCount
selCount = selCount - 1

ReDim obj(selCount) As Object
Dim i As Long
For i = 0 To selCount
Set obj(i) = swSelMgr.GetSelectedObject6(i + 1, -1)
Next i

Dim vLibRefs As Variant
vLibRefs = obj
swLibFeat.SetReferences (vLibRefs)

bool = swFeat.ModifyDefinition(swLibFeat, swModel, Nothing)

swModel.ClearSelection2 True

Outcomes