Custom Crosshair
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Custom Crosshair

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
Paul Richardson
Guest





Posted: Mon Dec 27, 2004 2:46 pm    Post subject: Custom Crosshair Reply with quote

Is it possible to create a custom crosshair
that can be toggled programmatically as
needed?

I need it to be an 8' ruler along the X-axis
with marks every 6 inches.

I currently send LISP thru the VBA Send
Command to insert a block of a ruler and
then delete the block. All I am looking for
is the pickpoint, but the ruler is necessary.

Thank You,

Paul

Back to top
Zibnaf



Joined: 23 Mar 2006
Posts: 1

Posted: Thu Mar 23, 2006 11:56 pm    Post subject: Bump Reply with quote

I am also looking for a way to create a scaleable crosshair in autoCAD.
Back to top
View user's profile Send private message
Fatty



Joined: 08 Jun 2006
Posts: 8
Location: Sankt-Petersburg, Russia

Posted: Fri Jun 09, 2006 7:00 am    Post subject: Re: Bump Reply with quote

Zibnaf wrote:
I am also looking for a way to create a scaleable crosshair in autoCAD.

Change by your needs
Code:

Option Explicit

Sub CrossHair()
Dim oLine As AcadLine
Dim pc
Dim p1(0 To 2) As Double
Dim p2(0 To 2) As Double
Dim p3(0 To 2) As Double
Dim p4(0 To 2) As Double
Dim lg, stp, lt, ang As Double

Const Pi As Double = 3.14159265359
ang = Pi / 2

On Error GoTo 0

pc = ThisDrawing.Utility.GetPoint(, "Pick center point")
lg = CDbl(InputBox("Enter crosshair length:", "Crosshair Length", 96))
stp = CDbl(InputBox("Enter step:", "Step", 8))
lt = CDbl(InputBox("Enter tick size:", "Tick Size", 3))

p1(0) = pc(0) - lt / 2: p1(1) = pc(1) - lg / 2: p1(2) = pc(2)
p2(0) = pc(0) + lt / 2: p2(1) = pc(1) - lg / 2: p2(2) = pc(2)

Set oLine = ThisDrawing.ModelSpace.AddLine(p1, p2)

Dim arrObj As Variant
arrObj = oLine.ArrayRectangular((lg \ stp) + 1, 1, 1, stp, 0, 0)

Dim icnt As Integer
icnt = (UBound(arrObj) - 1) \ 2

Dim lineObj As Object
Set lineObj = arrObj(icnt)

p3(0) = pc(0) - lg / 2: p3(1) = pc(1): p3(2) = pc(2)
p4(0) = pc(0) + lg / 2: p4(1) = pc(1): p4(2) = pc(2)

lineObj.StartPoint = p3
lineObj.EndPoint = p4
lineObj.color = acRed
lineObj.Update

Dim copyObj As Object
For icnt = 0 To UBound(arrObj)
Set copyObj = arrObj(icnt).Copy
copyObj.Rotate pc, ang
Next icnt

Dim copyLine As Object
Set copyLine = oLine.Copy
copyLine.Rotate pc, ang
ZoomExtents

End Sub


Back to top
View user's profile Send private message
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB