Download as pdf
Download as pdf
You are on page 1of 1
Add Assembly Components Dim Model As ModelDoc2 veDos Dim MyView As ModelView tiveView If Model.GetType <> swDocumentTypes_e.swDocASSEMBLY Then MsgSox("For use with assemb MsgBoxStyle. Exclamation) Exit sub End If Dim MyAssy As AssemblyDoc = Model End Sub The existing code gets the active document’s IModelDoc2 interface, then the ModelDoc’s IModel View interface and determines whether the active document is an assembly, If itis not, a message is presented to the user and the procedure exits. Otherwise, a specific reference to the [AssemblyDoc interface is retrieved from the ModelDoc. Processing Selections Before the selected part is added to the assembly we need to do some work to make sure the user has made a good selection, or any selection at all for that matter. Selection Count and Selection Type Based on our assumptions, we need to check to see if the user has selected a face or multiple edges. 7. Add the following code to the Process procedure Public Sub Process (ByVal swApp As SldWorks, ByVal PartPath As String) Dit Model As ModelDec2 = swApp.ActiveD Dim MyView As Modelview If Model.GetType <> swDocumentTypes, MsgBox ("For use with assemblies onl sgBoxStyle.Exclamation} Exit Sub End If Dim MyAssy As AssemblyDoc = Model iveview sWDOCASSEMBLY Then. ‘get the current selection ‘user should have selected the edge of a hole ‘or an entire face for parts to be inserted on 2t7

You might also like