Dear all,
I have done the program it working fine, but Its very very slow.please guide me to run fast.
Sub Check_InterSect_Contour_BL()Dim BlE As ElementDim Bl As LineElementDim bls As ShapeElementDim conte As ElementDim Cont As LineElementDim enumBL As ElementEnumeratorDim enumCont As ElementEnumeratorDim scanBl As ElementScanCriteriaDim scanCont As ElementScanCriteriaDim points() As Point3dDim Mat As Matrix3dDim Zval As VariantDim Zval1 As VariantDim Zval2 As VariantMat = Matrix3dIdentitySet scanBl = New ElementScanCriteriaSet scanCont = New ElementScanCriteriaDim cir As EllipseElementDim chlvlstr As StringDim chlevel As LevelDim olevel As Levelchlvlstr = "Error"Set chlevel = ActiveModelReference.Levels.Find(chlvlstr)If chlevel Is Nothing ThenSet chlevel = ActiveDesignFile.AddNewLevel(chlvlstr)ElseEnd IfscanBl.ExcludeAllLevelsscanBl.IncludeLevel ActiveDesignFile.Levels("Breakline")scanCont.ExcludeAllLevelsscanCont.IncludeLevel ActiveDesignFile.Levels("Contour")scanCont.IncludeLevel ActiveDesignFile.Levels("Contour_ma")Set enumBL = ActiveModelReference.Scan(scanBl)Do While enumBL.MoveNext Set BlE = enumBL.Current If BlE.IsLineElement Then Set Bl = enumBL.Current Set enumCont = ActiveModelReference.Scan(scanCont) Do While enumCont.MoveNext Set conte = enumCont.Current If conte.IsLineElement Then Set Cont = enumCont.Current Zval1 = Cont.StartPoint.Z If Bl.IsIntersectableElement Then points = Bl.AsIntersectableElement.GetIntersectionPoints(Cont, Mat) End If For t = 0 To UBound(points) Zval2 = points(t).Z Zval = Zval1 - Zval2 If Zval > 0.3 Then Set cir = CreateEllipseElement2(Nothing, points(t), 5, 5, Mat) ActiveModelReference.AddElement cir cir.Level = chlevel cir.Rewrite cir.Redraw End If Next Else MsgBox "plase drop other type to linestring" End If Loop ElseIf BlE.IsShapeElement Then Set bls = enumBL.Current Set enumCont = ActiveModelReference.Scan(scanCont) enumCont.BuildArrayFromContents enumCont.Reset Do While enumCont.MoveNext Set conte = enumCont.Current If conte.IsLineElement Then Set Cont = enumCont.Current Zval1 = Cont.StartPoint.Z If Bl.IsIntersectableElement Then points = bls.AsIntersectableElement.GetIntersectionPoints(Cont, Mat) End If For t = 0 To UBound(points) Zval2 = points(t).Z Zval = Zval1 - Zval2 If Zval > 0.1 Then Set cir = CreateEllipseElement2(Nothing, points(t), 5, 5, Mat) ActiveModelReference.AddElement cir cir.Level = chlevel cir.Rewrite cir.Redraw End If Next Else MsgBox "plase drop other type to linestring" End If Loop Else MsgBox "plase drop other type to linestring" End IfLoopEnd Sub
Unknown said:please guide me to run fast
You use the following code twice. But, since you don't assign a variable to the result of BuildArrayFromContents, the code does nothing.
enumBL.BuildArrayFromContents enumBL.Reset
You get an enumeration of breaklines. While iterating the breaklines array, you re-scan the model for contours. Hoist the second scan out of the iteration loop...
' Make enumeration of breaklines scanBl.ExcludeAllLevels scanBl.IncludeLevel ActiveDesignFile.Levels("Breakline") Set enumBL = ActiveModelReference.Scan(scanBl) ' Make enumeration of contours scanCont.ExcludeAllLevels scanCont.IncludeLevel ActiveDesignFile.Levels("Contour") scanCont.IncludeLevel ActiveDesignFile.Levels("Contour_ma") Set enumCont = ActiveModelReference.Scan(scanCont) Do While enumBL.MoveNext Set BlE = enumBL.Current If BlE.IsLineElement Then Set Bl = enumBL.Current Do While enumCont.MoveNext … Loop End If Loop
Regards, Jon Summers LA Solutions
Hi Jon,
Thanks for quick reply.May i know how to compare the intersection point height (Z) value for Contour and Breakline.Is there any way to get both intersected element height (Z) value?.
Regards,
Venugopal
Unknown said:Is there any way to get both intersected element height (Z) value?
Your problem is GetIntersectionPoints. According to VBA help: "For three dimensional elements, GetIntersectionPoints returns apparent intersections, ignoring differences along the Z-axis"
Use ProjectPointOnPerpendicular or similar to project the intersection point onto your element.
Thanks.Please explain with small example, I need to both lines Z values and how to Enumerate the Contour and Break lines.Please refer my screen.jpg file
Regards