iLogic Placed Dimension Failing at AddLinear Step
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am extremely new to object oriented programming and iLogic/VBA in general, but so far I've been able to overcome most of the issues I've come across. Currently, I'm roadblocked at an error I cannot seem to shake. Under the cases, I am able to complete cases 1 and 2, then it fails on case 3 and 4. The rule I'm working on is Straight_Pull_Bar_Dim and I'm working on the Interior View. I am dimensioning from the bottom of one assembly to a straight inset line on the bottom of a rounded piece. I originally tried dimensioning to the rounded piece directly, but I kept getting the same error, and even though the geometry is the same for the exterior view, I don't have any errors when that section runs. All attributes are named at the master assembly level. Is there some kind of limitation to a general linear dimension? From everything I understand, this should be working just fine. I can dimension the each intent as a single dimension (ie my intent 1 will dimension by itself at the oPT2 and my intent 2 will dimension itself at oPT2) but intent1 and intent2 together fail. It is failing at the oGeneralDims.AddLinear line inside of the while loop.
Error on line 154 in rule: Straight_Pull_Bar_Dim, in document: Sub Dwg MS Standard Stack V2.idw
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
'--- Initial Setup--- 'Lazy variables to switch between locking levers, pull bars, and recessed pulls Dim sHdwrName As String = "St" Dim sHdwrTag As String = "Straight<br/>Pull Bar" Dim dYVal As Double = (Parameter("Master Assembly 1.iam.Pull_Bar_Height")/Parameter("Master Assembly 1.iam.Unit_height")) 'Reference this document Dim oDrawDoc As DrawingDocument oDrawDoc = ThisDoc.Document 'Reference this drawing sheet Dim oSheet As Sheet oSheet = oDrawDoc.ActiveSheet 'Determine if the sheet is an interior view or exterior view to set-up variable names later to correctly pull the right attribute face Dim tViewName As String If oSheet.Name = "Exterior View:2" Then tViewName = "Exterior" Else tViewName = "Interior" End If 'References this drawing view Dim oView As DrawingView oView = ActiveSheet.View(tViewName+" View").View 'References the Drawing Model Dim oAssyDoc As AssemblyDocument oAssyDoc = ActiveSheet.View(tViewName + " View").ModelDocument 'Setting up the variable names to interior and exterior views Dim tPiece1 As String Dim tPiece2 As String 'Declaring Variables to determine how many (if any) panels are on the right or left side Dim iLPanels As Integer = Max(Parameter("Master Assembly 1.iam.Panels_L"), Parameter("Master Assembly 1.iam.Astragal_Panels_L")) Dim iRPanels As Integer = Max(Parameter("Master Assembly 1.iam.Panels_R"), Parameter("Master Assembly 1.iam.Astragal_Panels_R")) 'declaring a string variable to append if the component is an astragal Dim sLAst As String = "" Dim sRAst As String = "" 'Setting the variables to "Ast" if the component is an astragal component If Parameter("Master Assembly 1.iam.Astragal_Panels_L") > 0 Then sLAst = "Ast" End If If Parameter("Master Assembly 1.iam.Astragal_Panels_R") > 0 Then sRAst = "Ast" End If 'Readys code for creation of general dimensions Dim oGeneralDims As GeneralDimensions oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions '---Dimensions Prep--- 'Variable declarations to be used later on Dim oPt2 As Point2d Dim aoEdge4 As Face Dim aoEdge3 As Face Dim aoDrawCurves4 As DrawingCurve Dim aoDrawCurves3 As DrawingCurve Dim oDim2 As GeneralDimension Dim oDim2Att As AttributeSet Dim iCounter As Integer = 1 Dim sHandle As String Dim iXVal As Integer Dim bHandlePresent As Boolean Dim sInOut As String 'Setting variabel sIntOut, which is used for finding the correct parameter in the document If tViewName = "Exterior" Then sInOut = "_OUT" Else sInOut = "_IN" End If While iCounter < 5 Select iCounter Case 1 sHandle = ("LSH" & sLAst & (Parameter("Master Assembly 1.iam.Panels_L") + Parameter("Master Assembly 1.iam.Astragal_Panels_L")) & "X") bHandlePresent = Parameter("Master Assembly 1.iam.LSH_" + sHdwrName + sInOut) 'switches xval based on if it's interior or exterior since the view flips If tViewName = "Exterior" Then tPiece1 = ("BottomRailLSH" & sLAst & iLPanels & "X" & tViewName) iXVal = (oView.Left + 2.25) Else tPiece1 = ("BottomRailLSHC" & sLAst & iLPanels & "X" & tViewName) iXVal = (oView.Left + oView.Width - 2.25) End If Case 2 sHandle = ("LSHC" & sLAst & (Parameter("Master Assembly 1.iam.Panels_L") + Parameter("Master Assembly 1.iam.Astragal_Panels_L")) & "X") bHandlePresent = Parameter("Master Assembly 1.iam.LSHC_" + sHdwrName + sInOut) If tViewName = "Exterior" Then tPiece1 = ("BottomRailLSH" & sLAst & iLPanels & "X" & tViewName) iXVal = (oView.Left + oView.Width * (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") / (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") + Parameter("Master Assembly 1.iam.Frame_Dbl_RS"))) - 2.25) Else tPiece1 = ("BottomRailLSHC" & sLAst & iLPanels & "X" & tViewName) iXVal = (oView.Left + oView.Width * (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") / (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") + Parameter("Master Assembly 1.iam.Frame_Dbl_RS"))) + 2.25) End If Case 3 sHandle = ("RSHC" & sRAst & (Parameter("Master Assembly 1.iam.Panels_R") + Parameter("Master Assembly 1.iam.Astragal_Panels_R")) & "X") bHandlePresent = Parameter("Master Assembly 1.iam.RSHC_" + sHdwrName + sInOut) If tViewName = "Exterior" tPiece1 = ("BottomRailRSH" & sRAst & iRPanels & "X" & tViewName) iXVal = (oView.Left + oView.Width * (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") / (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") + Parameter("Master Assembly 1.iam.Frame_Dbl_RS"))) + 2.25) Else tPiece1 = ("BottomRailRSHC" & sRAst & iRPanels & "X" & tViewName) iXVal = (oView.Left + oView.Width * (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") / (Parameter("Master Assembly 1.iam.Frame_Dbl_LS") + Parameter("Master Assembly 1.iam.Frame_Dbl_RS"))) -2.25) End If Case 4 sHandle = ("RSH" & sRAst & (Parameter("Master Assembly 1.iam.Panels_R") + Parameter("Master Assembly 1.iam.Astragal_Panels_R")) & "X") bHandlePresent = Parameter("Master Assembly 1.iam.RSH_" + sHdwrName + sInOut) If tViewName = "Exterior" Then tPiece1 = ("BottomRailRSH" & sRAst & iRPanels & "X" & tViewName) iXVal = (oView.Left + oView.Width - 2.25) Else tPiece1 = ("BottomRailRSHC" & sRAst & iRPanels & "X" & tViewName) iXVal = (oView.Left + 2.25) End If End Select If bHandlePresent = TRUE Then tPiece2 = (sHdwrName + sHandle + tViewName) 'finds edges with particular attributes then takes the first instance oObjs = oAssyDoc.AttributeManager.FindObjects("Dim",tPiece1,"1") aoEdge4 = oObjs.Item(1) 'finds edges with particular attributes then takes the first instance oObjs = oAssyDoc.AttributeManager.FindObjects("Dim",tPiece2,"1") aoEdge3 = oObjs.Item(1) 'Find the drawing edge that represents the one with the attribute oDrawViewCurves = oView.DrawingCurves(aoEdge4) aoDrawCurves4 = oDrawViewCurves.Item(1) 'Find the drawing edge that represents the one with the attribute oDrawViewCurves = oView.DrawingCurves(aoEdge3) aoDrawCurves3 = oDrawViewCurves.Item(1) 'Placement position of the dimension 'oPt2 = ThisApplication.TransientGeometry.CreatePoint2d(x position, y position). 'oView.Left starts you at the left of the view window, oView.Width is the width of the view 'oView.Top starts you at the top of the view window, oView.Height is the height of the view oPt2 = ThisApplication.TransientGeometry.CreatePoint2d(iXVal, oView.Top - oView.Height * (1 - dYVal)) '---Creating Dimensions--- oDim2 = oGeneralDims.AddLinear(oPt2, oSheet.CreateGeometryIntent(aoDrawCurves3), oSheet.CreateGeometryIntent(aoDrawCurves4)) oDim2.Text.FormattedText = (sHdwrTag & ":<br/> <DimensionValue/><br/>Case: " & iCounter) 'Adds the tag "iLogic_Created" to the dimension so it can be removed by the delete dims rule. oDim2Att = oDim2.AttributeSets.Add("iLogic_Created") End If iCounter = iCounter + 1 End While