jloach Posted May 9, 2002 Share Posted May 9, 2002 VB - here we go! I have a VB application that worked with 4.2 called SetCutoffProperty. It went through every part in a scene, created a custom property called 'Cutoff", and assigned the third sizebox value to this property. It saved a ton of time. I created a dll from VB, then use the Add-On tool to add the function to IronCad. When I try to run it in 5.2, a window pops up saying "Object doesn't support this property or method". Unfortunately, it doesn't say which property or method this is. It must be something that was dropped or changed for version 5. Does anyone know how to debug this? Is there a log file somewhere that might have the line number or something? The documentation for objects and properties is very old (IC 2.0). Thank you! John Quote Link to comment Share on other sites More sharing options...
jloach Posted May 10, 2002 Author Share Posted May 10, 2002 It works!!!! Here's the SetCutoffProperties function. The lines that didn't work in IC5.2 are the ones using the 'ChildShapes' member, denoted by a *. This member now needs the 'ActivePage' object. The program adds a Custom Property called 'Cutoff' to every part and all parts within assemblies, and sets Cutoff equal to the third sizebox value. This program could be easily altered to set any properties within the parts and assemblies. I'm going to add to it to automate the PartNumber and Description fields in the Bill Of Material area. You need VB6 to create the dll, and you add the tool as an OLE Object, with the Object box filled in as 'SetCutoffProperties.SetCutoffProperty, and the Method box drops down as SetCutoffProperty. Make sure in VB that you've added a Project Reference to the 'IronCad Part Properties 1.0 Type Library". It's pretty crude. I'm not a programmer. Public Sub SetCutoffProperty(Application As Object) Dim i As Long Dim objPropertiesCollection As Object Dim objProperty As Object Dim objChildShape As Object Dim objTreeShape As Object Set objTreeShape = Nothing Dim objAllTreeShapes As Object ' Select the top level tree shapes * Set objAllTreeShapes = Application.ActivePage.Shape.ChildShapes Dim objAllShapes As Object ' Select the top level shapes * Set objAllShapes = Application.ActivePage.Shape.Components(triGroup).Item(1).Shapes ' If there is only one shape, check to see if it's an assembly. ' If it is, get the parts out of it. If (objAllTreeShapes.Count = 1) Then Select Case objAllShapes.Item(1).Type Case triGroupShape: Set objAllShapes = objAllShapes.Item(1).Components(triGroup).Item(1).Shapes Set objAllTreeShapes = objAllTreeShapes.Item(1).ChildShapes End Select End If ' Make sure that there is at least one shape If (objAllTreeShapes.Count > 0) Then ' Loop through all the shapes For i = 1 To objAllTreeShapes.Count ' Select the i'th tree shape Set objTreeShape = objAllTreeShapes.Item(i) ' First see if there is a custom properties collection which all the parts are using ' and if so we'll need to use it. Otherwise, we can apply the property to the shape ' selected only and not all instances. On Error Resume Next Set objPropertiesCollection = objTreeShape.DataObject(triClassIDCustomProperties, True) If ((Err.Number <> 0) Or (objPropertiesCollection Is Nothing)) Then Set objPropertiesCollection = objTreeShape.DataObject(triClassIDCustomProperties, False) If ((Err.Number <> 0) Or (objPropertiesCollection Is Nothing)) Then Set objPropertiesCollection = New CPPropCollection objTreeShape.DataObject(triClassIDCustomProperties, False) = objPropertiesCollection End If End If ' For parts only, get the child shape, in this case the intellishape that makes the part Select Case objAllShapes.Item(i).Type Case triCompoundShape: Set objChildShape = objAllShapes.Item(i).Components(triHistory).Item(1).Shapes.Item(1) Case Else: Set objChildShape = Nothing End Select ' Now add the Cutoff property Set objProperty = New CPPropObj objProperty.Value = Round(objChildShape.Components(triSizeBox).Item(1).Variable(triHeight).Value, 3) objProperty.Name = "Cutoff" objPropertiesCollection.Add objProperty Next End If End Sub Quote Link to comment Share on other sites More sharing options...
Chris Lohman Posted May 10, 2002 Share Posted May 10, 2002 Nice Quote Link to comment Share on other sites More sharing options...
jloach Posted May 11, 2002 Author Share Posted May 11, 2002 Hi Chris I see how to set the Name of an item, eg objShape.Name = objShape.Name & "1" adds a 1 to the end of the existing part name. Do you know how to access the PartNumber and Description? Can't find those thingys anywhere! I guess this thread should be going into the "Custom Stuff" forum. Thank you, John Quote Link to comment Share on other sites More sharing options...
Guest Maurizio Morandi Posted May 11, 2002 Share Posted May 11, 2002 Ciao John, here is the code.... Enjoy Maurizio Public Sub UpdateSetBOMData(objtreeShape as object, strPN as string, strDescr As String) Dim pBOMProperties As Object Dim pProperty As Object Dim cnt As Integer If (Not treeShape Is Nothing) Then On Error Resume Next Set pBOMProperties = treeShape.DataObject(triClassIDBOMProperties, True) If (pBOMProperties Is Nothing Or err.Number <> 0) Then Set pBOMProperties = New CBOMMaster treeShape.DataObject(triClassIDBOMProperties, False) = pBOMProperties End If On Error GoTo 0 If (Not pBOMProperties Is Nothing) Then pBOMProperties.Description = strDescr pBOMProperties.PartNumber = strPN End If End If End Sub quote:Originally posted by jloach: Hi Chris I see how to set the Name of an item, eg objShape.Name = objShape.Name & "1" adds a 1 to the end of the existing part name. Do you know how to access the PartNumber and Description? Can't find those thingys anywhere! I guess this thread should be going into the "Custom Stuff" forum. Thank you, John id=quote>id=quote> PROGRESS SOLUZIONI CAD Srl Via Bellaria 3 - 21052 Busto Arsizio (VA) ITALY Tel. +39/331/67.77.53 Fax +39/331/63.62.62 EMail maurizio.morandi@progresscad.it WEB www.ironcad.it Quote Link to comment Share on other sites More sharing options...
jloach Posted May 11, 2002 Author Share Posted May 11, 2002 Beautiful!!! Thank you Maurizio. Regards, John Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.