Type txtBordergg As LonglineWeight As Integercolor As Longlevel As StringEnd TypePublic tBorder As txtBorder' ===============================================================================Sub textBorder()Dim sScanEnumerator As ElementEnumeratorDim sElement As elementDim gg As LongDim sFence As FencetBorder.lineWeight = 4tBorder.color = 16tBorder.level = "Border"Set sFence = ActiveDesignFile.FenceIf ActiveModelReference.AnyElementsSelected Or sFence.IsDefined ThenIf ActiveModelReference.AnyElementsSelected ThenSet sScanEnumerator = ActiveModelReference.GetSelectedElementsElseSet sScanEnumerator = sFence.GetContentsEnd IfActiveModelReference.UnselectAllElementsDo While sScanEnumerator.MoveNextSet sElement = sScanEnumerator.CurrentIf sElement.Type = msdElementTypeText Or sElement.Type = msdElementTypeTextNode ThenbesuTextBorder sElement, tBorderEnd IfLoopElseCommandState.StartLocate New classTextBorderEnd IfEnd SubFunction besuTextBorder(sElement As element, tBorder As txtBorder)gg = UpdateGraphicGroupNumber 'CurrentGraphicGrouptBorder.gg = ggIf sElement.Type = msdElementTypeTextNode ThendropElemTN sElement, tBorderEnd IfIf sElement.Type = msdElementTypeText ThendropElemT sElement, tBorderEnd IfsElement.GraphicGroup = tBorder.ggsElement.RewriteEnd Function' ===============================================================================Function dropElemTN(oEle As element, tBorder As txtBorder)ShowStatus ""On Error GoTo NoElementIf oEle.IsDroppableElement ThenDim oDE As DroppableElementDim oEE As ElementEnumeratorSet oDE = oEleSet oEE = oDE.DropDo While oEE.MoveNextIf oEE.Current.Type = msdElementTypeText ThendropElemT oEE.Current, tBorder.ggEnd IfLoopEnd IfExit FunctionNoElement:ShowStatus "Element not found"End Function' ===============================================================================Function dropElemT(oEle As element, tBorder As txtBorder)ShowStatus ""On Error GoTo NoElementIf oEle.IsDroppableElement ThenDim oNew As elementDim oDE As DroppableElementDim oEE As ElementEnumeratorSet oDE = oEleSet oEE = oDE.DropDo While oEE.MoveNextSet oNew = oEE.CurrentActiveModelReference.AddElement oNewoNew.lineWeight = tBorder.lineWeightoNew.color = tBorder.coloroNew.GraphicGroup = tBorder.ggoNew.level = besuLevel(tBorder.level & "_" & oEle.level.Name)oNew.RewriteIf oNew.IsClosedElement ThenoNew.AsClosedElement.FillMode = msdFillModeNotFilledoNew.RewriteEnd IfIf oNew.IsCellElement ThenCellElem oNew.AsCellElementEnd IfLoopEnd IfExit FunctionNoElement:ShowStatus "Element not found"End Function' ===============================================================================Function CellElem(cEle As CellElement)Dim cComponents As ElementEnumeratorOn Error GoTo NoElementSet cComponents = cEle.GetSubElementsDo While cComponents.MoveNextDim cComponent As elementSet cComponent = cComponents.CurrentIf cComponent.IsClosedElement ThencComponent.AsClosedElement.FillMode = msdFillModeNotFilledcComponent.RewriteEnd IfLoop'cEle.RewriteExit FunctionNoElement:ShowStatus "Element not found"End Function
Function besuLevel(levname As String) As level' ===============================================================================Set besuLevel = ActiveDesignFile.Levels.Find(levname)If besuLevel Is Nothing ThenCadInputQueue.SendKeyin "level create " & Chr(34) & levname & Chr(34)'Set besuLevel = ActiveDesignFile.Levels.Find(levname)End IfSet besuLevel = ActiveDesignFile.Levels.Find(levname)
End Function
class modülüne de alttaki kodlar yazılır. class modülünün ismi önemli
classTextBorder
kodları kod projemize ekledikten sonraOption ExplicitImplements ILocateCommandEvents' ===============================================================================' DATAPOINT HANDLER' ===============================================================================Private Sub ILocateCommandEvents_Accept(ByVal element As element, point As Point3d, ByVal View As View)besuTextBorder element, tBorder' CommandState.StartPrimitive New classDrawValveEnd Sub' ===============================================================================' CLEANUP HANDLER' ===============================================================================Private Sub ILocateCommandEvents_Cleanup()End Sub' ===============================================================================' DYNAMICS HANDLER' ===============================================================================Private Sub ILocateCommandEvents_Dynamics(point As Point3d, _ByVal View As View, ByVal DrawMode As MsdDrawingMode)End Sub' ===============================================================================' LOCATE FAILED HANDLER' ===============================================================================Private Sub ILocateCommandEvents_LocateFailed()CommandState.StartLocate New classTextBorderEnd Sub' ===============================================================================' LOCATE FILTER - lines only' ===============================================================================Private Sub ILocateCommandEvents_LocateFilter(ByVal element As element, _point As Point3d, Accepted As Boolean)Accepted = FalseIf (element.IsTextElement) Or (element.IsTextNodeElement) ThenAccepted = TrueEnd IfEnd Sub' ===============================================================================' RESET HANDLER' ===============================================================================Private Sub ILocateCommandEvents_LocateReset()CommandState.StartLocate New classTextBorder' CommandState.StartDefaultCommandEnd Sub' ===============================================================================' LOCATE INITIALIZATION' ===============================================================================Private Sub ILocateCommandEvents_Start()Dim lc As LocateCriteriaSet lc = CommandState.CreateLocateCriteria(False)CommandState.SetLocateCriteria lcCommandState.EnableAccuSnapShowCommand "Place Component"ShowPrompt "Select Text or TextNode"End Sub
vba run textBorder
ile programı çalıştırıyoruz.
Hiç yorum yok:
Yorum Gönder