XY-Axis Form


The XY Axis form code. del_blk is sub to delete all axis blocks of the same name (the references) then delete the block (definition)

Sub draw_axis()
Dim Xmin As Double, Xmax As Double, Xscl As Double, Xtick As Double
Dim Ymin As Double, Ymax As Double, Yscl As Double, Ytick As Double
Dim strblkname As String

Call connect_acad
Call set_pt0 'calls a sub to init global origin point

Xmin = frm_axis.txt_xmin
Xmax = frm_axis.txt_xmax
Xscl = frm_axis.txt_xscl
Xtick = frm_axis.txt_xtick

Ymin = frm_axis.txt_ymin
Ymax = frm_axis.txt_ymax
Yscl = frm_axis.txt_yscl
Ytick = frm_axis.txt_ytick

strblkname = frm_axis.txt_strblkname
'deletes the current axis of the same name
Call del_blk(strblkname)

Call draw_xy_axis(Xmin, Xmax, Xscl, Xtick, Ymin, Ymax, Yscl, Ytick, strblkname)
End Sub

Sub reset_axis_form()
frm_axis.txt_xmin = -12
frm_axis.txt_xmax = 12
frm_axis.txt_xscl = 1
frm_axis.txt_xtick = 0.5

frm_axis.txt_ymin = -12
frm_axis.txt_ymax = 12
frm_axis.txt_yscl = 1
frm_axis.txt_ytick = 0.5

frm_axis.txt_strblkname = "std_xy_axis"
End Sub

Sub set_trig_nums()
'pi is set as public constant
frm_axis.txt_xmin = -pi * 2
frm_axis.txt_xmax = pi * 2
frm_axis.txt_xscl = pi / 4
frm_axis.txt_xtick = pi / 8

frm_axis.txt_ymin = -6
frm_axis.txt_ymax = 6
frm_axis.txt_yscl = 1
frm_axis.txt_ytick = 0.25

frm_axis.txt_strblkname = "trig_xy_axis"
End Sub

Sub del_blk(strname As String)
'deletes all occurences of named block and then deletes definition
Dim blockdef As AcadBlock
Dim blockRef As AcadBlockReference
Dim entity As AcadEntity

For Each entity In acadDoc.ModelSpace
        If TypeOf entity Is AcadBlockReference Then
            Set blockRef = entity
            If blockRef.Name = strname Then
            End If
        End If
 On Error Resume Next
Set blockdef = acadDoc.Blocks.Item(strname)
 On Error GoTo 0

End Sub


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s