Easy way to align view/scale label?

Easy way to align view/scale label?

Anonymous
Not applicable
1,281 Views
21 Replies
Message 1 of 22

Easy way to align view/scale label?

Anonymous
Not applicable

Good Morning All,

Looking for an easy way to align View/Scale labels without having to sketch. Would think there would be an align option like you can align the actual views? Thanks in advance, have a good weekend.

 

-Josh Applegate

Inventor User for 6 weeks and counting!

Inventor 2013

0 Likes
Accepted solutions (1)
1,282 Views
21 Replies
Replies (21)
Message 21 of 22

rhasell
Advisor
Advisor

Hi

I thought I would add another rule which you may find useful. Most of it comes from the forum, I added a few small tweaks. Credit is given to the author. This will align views based on a horizontal or vertical line.

 

'Got this from Bart Den Otter
'Autodesk Forums
'https://forums.autodesk.com/t5/inventor-forum/aligning-views-to-a-line/td-p/7186354
'Good Code
'21.02.2020

Sub Main()

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

Dim oCurve1, oCurve2 As DrawingCurveSegment
oCurve1 = GetCurve1(oDoc)
oCurve2 = GetCurve2(oDoc)

Dim oView1, oView2 As DrawingView
oView1 = oCurve1.Parent.Parent
oView2 = oCurve2.Parent.Parent

Dim Curve1Point1, Curve1Point2, Curve2Point1, Curve2Point2, View1Point, View2Point As Point2d
Curve1Point1 = oCurve1.StartPoint
Curve1Point2 = oCurve1.EndPoint
Curve2Point1 = oCurve2.StartPoint
Curve2Point2 = oCurve2.EndPoint

If oView1.Name = oView2.Name Then
MessageBox.Show("Select lines from different views", "Align view error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Exit Sub
End If

If (Round((Curve1Point1.X - Curve1Point2.X) * 1e8) = 0 And Round((Curve2Point1.X - Curve2Point2.X) * 1e8) = 0) Then
MoveView = Curve1Point1.X - Curve2Point1.X
oView2Point = oView2.Position
oView2Point.X = oView2Point.X + MoveView
oView2.Position = oView2Point
Else If (Round((Curve1Point1.Y - Curve1Point2.Y) * 1e8) = 0 And Round((Curve2Point1.Y - Curve2Point2.Y) * 1e8) = 0) Then
MoveView = Curve1Point1.Y - Curve2Point1.Y
oView2Point = oView2.Position
oView2Point.Y = oView2Point.Y + MoveView
oView2.Position = oView2Point
Else
MessageBox.Show("Lines are not horizontal or vertical or not in the same orientation.", "Align view error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
MsgBox(Curve1Point1.Y - Curve1Point2.Y)
MsgBox(Curve2Point1.Y - Curve2Point2.Y)
Exit Sub
End If
oAgainQ()
End Sub

Sub oAgainQ()
oAgain = MessageBox.Show("Again", "Rinse and Repeat", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
If oAgain = vbYes
Main()
End If
End Sub



Private Function GetCurve1(ByVal oDoc As DrawingDocument) As DrawingCurveSegment
Dim Curve As DrawingCurveSegment
Curve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select first line to align")
Return Curve
End Function

Private Function GetCurve2(ByVal oDoc As DrawingDocument) As DrawingCurveSegment
Dim Curve As DrawingCurveSegment
Curve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select second line to align")
Return Curve
End Function

 

Reg
2026.1
Message 22 of 22

WCrihfield
Mentor
Mentor

Though not exactly what this main forum topic is labeled for, since I saw an interest in drawing view alignment show back up again, I figured it wouldn't hurt to drop a couple more examples in here of my own.  Both of these examples are mostly the same, just in different forms.  One is a whole external iLogic rule, with 2 routines, and includes some manual user interactions.  The other is just a Sub routine with 3 input parameters, and contains no manual user interactions.  The Sub routine was created using most of the same code as the rule, except for the user prompts, so that it could be referenced &/or called remotely, and possibly called multiple times from within the same 'main' (calling) routine.  Sometimes I just use a whole external rule as I would a Sub or Function, where I can 'send' data to it, &/or 'receive' data back from it, using a NameValueMap and the iLogic 'RuleArguments' also.  I do not recall if I have ever posted either of these on the forum before, or I would have just posted the Link(s) instead of the text files.  I never really used either of them that much since we already have 3 built-in view alignment options, but hopefully someone else can get more use from them than I did.  The 2 text files containing the example codes are attached to this reply, to keep this entry brief.  (I did update both of them a bit just before posting them, because my coding style keeps evolving over time, and they needed it. 😊 )

Wesley Crihfield

EESignature

(Not an Autodesk Employee)