Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NosLinesplan = myWorksheet.Range("b97")
MsgBox ("No. of lines to be drawn in plan are " + CStr(NosLinesplan))
countery1 = 0
No_of_spans1 = Int(No_of_spans / 2)
For y = 1 To No_of_spans1
MsgBox ("countery " + CStr(countery1))
counterxx = 0
For x = 1 To NosLinesplan
CurrRow = 99
CurrCol = 1
MsgBox (" countery is " + CStr(countery1))
StartPoint(0) = myWorksheet.Cells(CurrRow + counterxx, CurrCol).Value +
countery1: _
StartPoint(1) = myWorksheet.Cells(CurrRow + counterxx, CurrCol + 1).Value: _
StartPoint(2) = myWorksheet.Cells(CurrRow + counterxx, CurrCol + 2).Value
EndPoint(0) = myWorksheet.Cells(CurrRow + counterxx, CurrCol + 3).Value +
countery1: _
EndPoint(1) = myWorksheet.Cells(CurrRow + counterxx, CurrCol + 4).Value: _
EndPoint(2) = myWorksheet.Cells(CurrRow + counterxx, CurrCol + 5).Value
Set lineObj = ThisDrawing.ModelSpace.AddLine(StartPoint, EndPoint)
lineObj.Layer = "drawing"
lineObj.color = acCyan
lineObj.Lineweight = acLnWt035
lineObj.LinetypeScale = 0.25
lineObj.Linetype = "continuous"
lineObj.Update
counterxx = counterxx + 1
Next x
countery1 = countery1 + Length_of_spans
'MsgBox ("countery " + CStr(countery))
Next y
End If
End Sub
Private Function Example1_AddLine(x1, y1, z1, x2, y2, z2, NosLines, noArrayElem) As
AcadLine
' This example adds a line in model space
Dim lineObj1 As AcadLine
'Dim startPoint(1 To 18) As Double
'Dim endPoint(1 To 18) As Double
'Dim x1 As Double
'Dim y1 As Double
'Dim z1 As Double
'Dim x2 As Double
'Dim y2 As Double
'Dim z2 As Double
'Define the start and end points for the line
ReDim StartPoint(1 To NosLines * 2) As Double
ReDim EndPoint(1 To NosLines * 2) As Double
StartPoint(1) = x1: StartPoint(2) = y1: StartPoint(2) = z1
'MsgBox (" start point" + CStr(startPoint(0)))
EndPoint(0) = x2: EndPoint(1) = y2: EndPoint(2) = z2
'Create the line in model space
Set lineObj1 = ThisDrawing.ModelSpace.AddLine(StartPoint, EndPoint)
ZoomAll
End Function
Sub Ch5_CreateLinearDimension()
Dim dimObj As AcadDimAligned
Dim dimObj1 As AcadDimRotated
Dim objDimstyle As AcadDimStyle
Dim NosLines As Integer
Dim lineObj As AcadLine
Dim counter As Integer
Dim StartPoint(0 To 2) As Double
Dim EndPoint(0 To 2) As Double
Dim TextPosition(0 To 2) As Double
Set objDimstyle = ThisDrawing.DimStyles.Add("manish")
Set myExcel = GetObject(, "Excel.Application")
filepath = "f:\piercap.xls"
myExcel.Workbooks.Open (filepath)
Set myWorksheet = myExcel.Worksheets("Sheet4")
myExcel.Visible = True
NosLines = myWorksheet.Range("b2")
counter = 0
For x = 1 To NosLines
CurrRow = 4
CurrCol = 1
StartPoint(0) = myWorksheet.Cells(CurrRow + counter, CurrCol).Value: _
'MsgBox ("current row " + CStr(CurrRow + counter))
'MsgBox ("current column " + CStr(CurrCol + 5))
StartPoint(0) = myWorksheet.Cells(CurrRow + counter, CurrCol).Value: _
StartPoint(1) = myWorksheet.Cells(CurrRow + counter, CurrCol + 1).Value: _
StartPoint(2) = myWorksheet.Cells(CurrRow + counter, CurrCol + 2).Value
EndPoint(0) = myWorksheet.Cells(CurrRow + counter, CurrCol + 3).Value: _
EndPoint(1) = myWorksheet.Cells(CurrRow + counter, CurrCol + 4).Value: _
EndPoint(2) = myWorksheet.Cells(CurrRow + counter, CurrCol + 5).Value
'MsgBox ("current row " + CStr(CurrRow + counter + 6))
TextPosition(0) = myWorksheet.Cells(CurrRow + counter, CurrCol + 6).Value: _
TextPosition(1) = myWorksheet.Cells(CurrRow + counter, CurrCol + 7).Value: _
TextPosition(2) = myWorksheet.Cells(CurrRow + counter, CurrCol + 8).Value
MsgBox ("current row " + CStr(CurrRow + counter))
MsgBox ("current col " + CStr(CurrCol + 6))
MsgBox ("current col " + CStr(CurrCol + 7))
MsgBox ("current col " + CStr(CurrCol + 8))
'If myWorksheet.cells(CurrRow + counter, CurrCol).Value _
' <> myWorksheet.cells(CurrRow + counter, CurrCol + 3).Value Then
Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(StartPoint, EndPoint,
TextPosition)
' Else
' Set dimObj1 = ThisDrawing.ModelSpace.AddDimRotated _
' (StartPoint, EndPoint, TextPosition, 45)
' dimObj.StyleNames = objDimstyle
'End If
counter = counter + 1
Next x
ZoomAll
End Sub
Sub Ch4_CreateMText()
Dim mtextObj As AcadMText
Dim insertPoint(0 To 2) As Double
Dim width As Double
Dim textString As String
insertPoint(0) = 2
insertPoint(1) = 2
insertPoint(2) = 0
width = 4
' textString = "This is a text string for the mtext object."
textString = "hello."
' Create a text Object in model space
Set mtextObj = ThisDrawing.ModelSpace. _
AddMText(insertPoint, width, textString)
ZoomAll
End Sub
Sub Example_AddLeader()
' This example creates a leader in model space.
' The leader is not attached to any annotation object
' in this example.
End Sub
Sub Ch5_CreateMText()
Dim mtextObj As AcadMText
Dim insertPoint(0 To 2) As Double
Dim width As Double
Dim MyValue As String
Dim textString As String
Dim counter As Integer
Dim colcounter As Integer
Set myExcel = GetObject(, "Excel.Application")
filepath = "f:\piercap.xls"
myExcel.Workbooks.Open (filepath)
Set myWorksheet = myExcel.Worksheets("Sheet2")
'myWorksheet.Range("X1") = "Get Range"
myExcel.Visible = True
NosLines = myWorksheet.Range("b2")
MsgBox (" NosLines " + CStr(NosLines))
counter = 0
colcounter = 0
For y = 1 To 9
For x = 1 To NosLines
CurrRow = 3 + counter
CurrCol = 1 + colcounter
currpointx = 1 + colcounter * width
currpointy = 1 - counter
currpointz = 0
'MsgBox (" counter is " + CStr(counter))
insertPoint(0) = currpointx
'MsgBox ("xcord1 " + CStr(currpointx))
insertPoint(1) = currpointy
'MsgBox ("ycord1 " + CStr(currpointy))
insertPoint(2) = currpointz
'MsgBox ("xcord1 " + CStr(currpointz))
width = 4
MyValue = myWorksheet.Cells(CurrRow, CurrCol).Value
textString = Str(MyValue)
'MsgBox ("text is" + CStr(textString))
Set mtextObj = ThisDrawing.ModelSpace. _
AddMText(insertPoint, width, textString)
counter = counter + 1
Next x
counter = 0
colcounter = colcounter + 1
Next y
ZoomAll
End Sub
Sub Ch10_InsertingABlock()
' Define the block
Dim blockObj As AcadBlock
Dim insertionPnt(0 To 2) As Double
insertionPnt(0) = 0
insertionPnt(1) = 0
insertionPnt(2) = 0
Set blockObj = ThisDrawing.Blocks.Add _
(insertionPnt, "CircleBlock")
End Sub
Public Sub pierplan()
' this macro draws sectional elevation and plan of piers and footing
Dim NosLines As Integer
Dim lineObj As AcadLine
Dim CirObj As AcadArc
Dim counter, No_of_spans As Integer
Dim StartAngle, EndAngle As Double
Set myExcel = GetObject(, "Excel.Application")
filepath = "C:\DATA\New folder\GADcircularpierboxabutment.xls"
myExcel.Workbooks.Open (filepath)
Set myWorksheet = myExcel.Worksheets("superstructure")
'myWorksheet.Range("X1") = "Get Range"
myExcel.Visible = True
ReDim StartPoint(0 To 2) As Double
ReDim EndPoint(0 To 2) As Double
Dim newlayer As AcadLayer
Dim layColor As AcadAcCmColor
Set newlayer = ThisDrawing.Layers.Add("drawing")
ThisDrawing.ActiveLayer = newlayer
'Dim col As New AcadAcCmColor
' col.ColorMethod = AutoCAD.acColorMethodForeground
' Set the layer to the color
' Set layColor = _AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")
' Call layColor.SetRGB(122, 199, 25)
' ThisDrawing.ActiveLayer.TrueColor = layColor
' col.ColorMethod = AutoCAD.acColorMethodByLayer
No_of_spans = myWorksheet.Range("p18")
'No_of_spans = InputBox(Message, Title, Default)
MsgBox ("No_of_spans " + CStr(No_of_spans))
Length_of_spans = myWorksheet.Range("p12")
MsgBox ("Length of spans " + CStr(Length_of_spans))
Noscirclesplan2 = myWorksheet.Range("b145")
MsgBox ("No. of circles to be drawn in plan are " + CStr(Noscirclesplan2))
counterz1 = 0
For z = 1 To Noscirclesplan2
CurrRow = 147
CurrCol = 1
MsgBox (" counterz is " + CStr(counterz1))
CenterPoint(0) = myWorksheet.Cells(CurrRow + counterz1, CurrCol).Value: _
CenterPoint(1) = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 1).Value: _
CenterPoint(2) = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 2).Value
radius = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 3).Value
StartAngle = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 4).Value
EndAngle = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 5).Value
Set CirObj = ThisDrawing.ModelSpace.AddArc(CenterPoint, radius, StartAngle,
EndAngle)
CirObj.Layer = "drawing"
CirObj.color = acCyan
CirObj.Lineweight = acLnWt035
CirObj.LinetypeScale = 0.25
CirObj.Linetype = "continuous"
CirObj.Update
counterz1 = counterz1 + 1
Next z
End If
End Sub
Sub testnose()
Dim NosLines, NosLinesplan1, NosLinesplan2, Noscirclesplan, Noscirclesplan1,
Noscirclesplan2 As Integer
ReDim CenterPoint(0 To 2) As Double
Noscirclesplan2 = myWorksheet.Range("b145")
MsgBox ("No. of circles to be drawn in plan are " + CStr(Noscirclesplan2))
counterz1 = 0
For z = 1 To Noscirclesplan2
CurrRow = 147
CurrCol = 1
MsgBox (" counterz is " + CStr(counterz1))
CenterPoint(0) = myWorksheet.Cells(CurrRow + counterz1, CurrCol).Value: _
CenterPoint(1) = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 1).Value: _
CenterPoint(2) = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 2).Value
radius = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 3).Value
StartAngle = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 4).Value
EndAngle = myWorksheet.Cells(CurrRow + counterz1, CurrCol + 5).Value
Set CirObj = ThisDrawing.ModelSpace.AddArc(CenterPoint, radius, StartAngle,
EndAngle)
CirObj.Layer = "drawing"
CirObj.color = acCyan
CirObj.Lineweight = acLnWt035
CirObj.LinetypeScale = 0.25
CirObj.Linetype = "continuous"
CirObj.Update
counterz1 = counterz1 + 1
Next z
End Sub