SendCommand

SendCommand

Anonymous
Not applicable
360 Views
2 Replies
Message 1 of 3

SendCommand

Anonymous
Not applicable
Hello!


I am working at a macro which will draw 3D U, I beam.
I made the from polylines, the 2D section, but I don't find any method to fillet them. So I choose to "pedit" them and then to use "fillet" command.



Dim objLinii(7) As AcadLWPolyline
..........................

' in this part I draw polylines

...........................
' here I am trying to "pedit" but I get a message that the method is not supported by object:

ThisDrawing.SendCommand "pedit" & vbCr & objLinii(0) & "j" & vbCr & objLinii(1) & vbCr

' here it should be the "fillet" command.

Can you tell me why I get the error?
Thank you!
0 Likes
361 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Use the FILLET command instead of PEDIT:


Public Sub FilletPLine()
Dim objPLine As AcadLWPolyline
Dim dblVertices(0 To 7) As Double
Dim strCommand As String

' Create the polyline

dblVertices(0) = 0#
dblVertices(1) = 0#

dblVertices(2) = 10#
dblVertices(3) = 0#

dblVertices(4) = 10#
dblVertices(5) = 10#

dblVertices(6) = 0#
dblVertices(7) = 10#

Set objPLine = ThisDrawing.ModelSpace.AddLightWeightPolyline(dblVertices)

' Fillet the polyline

strCommand = "FILLET R 2.0 "
ThisDrawing.SendCommand strCommand

strCommand = "FILLET P L "
ThisDrawing.SendCommand strCommand
End Sub
0 Likes
Message 3 of 3

Anonymous
Not applicable
This is a bit of code a wrote a while back -- just send it the LWpline, vertex number, and radius and it will fillet the vertex (if allowable). If you are doing several fillets, its best to work from last to first -- as adding each fillet adds a new vertex:

'This function will add a vertex infront of the vertice _
to be "filleted", adjust the previous point, and _
add a bulge factor to the new segment
Public Function FilletVertex(ByVal LWPline As AcadLWPolyline, _
ByVal VertexNumber As Integer, ByVal Radius As Double)
On Error Resume Next

Dim AngleToVertex As Double
Dim AngleFromVertex As Double
Dim AngleIncluded As Double
Dim ptList As Variant
Dim LastVertex As Integer
Dim PrevVertex As Integer
Dim NextVertex As Integer
Dim pt1 As Variant
Dim pt2 As Variant
Dim pt2a As Variant
Dim pt2b As Variant
Dim pt3 As Variant
Dim VertexA(1) As Double
Dim VertexB(1) As Double
Dim AngleC As Double
Dim AngleA As Double
Dim Chamfer As Double
Dim Util As AcadUtility
Dim PI as double

PI = 3.14159265358979
Set Util = ThisDrawing.Utility

If Not Radius > 0 Then Exit Function

With LWPline
ptList = .Coordinates

LastVertex = (UBound(ptList) - 1) / 2
If VertexNumber > LastVertex Then VertexNumber = 0
NextVertex = VertexNumber + 1
PrevVertex = VertexNumber - 1
If NextVertex > LastVertex Then NextVertex = 0
If PrevVertex < 0 Then PrevVertex = LastVertex

If NextVertex = PrevVertex Then Exit Function

pt1 = .Coordinate(PrevVertex)
pt2 = .Coordinate(VertexNumber)
pt3 = .Coordinate(NextVertex)

ReDim Preserve pt1(2): pt1(2) = 0
ReDim Preserve pt2(2): pt2(2) = 0
ReDim Preserve pt3(2): pt3(2) = 0

AngleToVertex = Util.AngleFromXAxis(pt2, pt1)
AngleFromVertex = Util.AngleFromXAxis(pt2, pt3)

AngleIncluded = (AngleToVertex - AngleFromVertex)
If AngleIncluded > PI Then
AngleIncluded = AngleIncluded - (2 * PI)
ElseIf AngleIncluded < -PI Then
AngleIncluded = AngleIncluded + (2 * PI)
End If

Chamfer = Radius * _
Tan((PI - (Abs(AngleIncluded))) / 2)

pt2b = Util.PolarPoint(pt2, _
AngleFromVertex, Chamfer)
VertexB(0) = pt2b(0): VertexB(1) = pt2b(1)
.Coordinate(VertexNumber) = VertexB

pt2a = Util.PolarPoint(pt2, _
AngleToVertex, Chamfer)
VertexA(0) = pt2a(0): VertexA(1) = pt2a(1)
.AddVertex VertexNumber, VertexA

.SetBulge VertexNumber, _
Tan((IIf(AngleIncluded > 0, PI, -PI) _
- AngleIncluded) / 4#)

End With
End Function
0 Likes