- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning,
Got an interesting one here. Basically I have a set drawing template that i'm creating that sets up the basic views and what not for the draftsmen. I created a box2d object that represents the area in which I wish these 4 first views get placed.
From there I passed a bunch of equations for placement and scaling. However My loop checks the view size width and the view size height against the values created from the box2d equations. However no matter how i set this loop up. The scale will only apply to 3 iterations. After it will enter an endless state, even though the returned values in a message box show that we should be rescaling.
Dim oPage1Box As Box2d = oTG.CreateBox2d()
oPage1Box.MinPoint = Box1Point
oPage1Box.MaxPoint = Box2Point
Dim oPage1BoxWidth As Double = Box2Point.X - Box1Point.X
Dim oPage1BoxHeight As Double = Box2Point.Y - Box1Point.Y
'MessageBox.Show(oPage1BoxWidth.ToString & " " & oPage1BoxHeight.ToString) 'This checks the size of the x and y of the box object
Dim oBox1YHeight As Double = oPage1BoxHeight /2 + .635 'This variable represents the distance from center to bottom of page for page one view placement
Dim oBox1XWidthStart As Double = (oPage1BoxWidth / 4) / 2 + .635 'This variable represents the distance from left edge of sheet to center start point for first page 1st view placement
Dim oBox1XWidthCenter As Double = (oPage1BoxWidth / 4) / 2 'This value represents the distance on the x axis for view spacing.
'Messagebox.Show("The first value should match 6.945 " & oBox1Yheight.ToString & " This second value should match 4.68 " & oBox1XWidthStart.ToString & " The thrid value should match 4.0456 " & oBox1XWidthCenter.ToString) 'This verifies the correct distance values mathmatically.
'Below establishes the point objects that each view on page one will be attached to upon runtime.
Dim PageOneViewOne As Point2d = oTG.CreatePoint2d(oBox1XWidthStart, oBox1YHeight)
Dim PageOneViewTwo As Point2d = oTG.CreatePoint2d(oBox1XWidthStart + oBox1XWidthCenter * 2, oBox1YHeight)
Dim PageOneViewThree As Point2d = oTG.CreatePoint2d(oBox1XWidthStart + oBox1XWidthCenter * 4, oBox1YHeight)
Dim PageOneviewFour As Point2d = oTG.CreatePoint2d(oBox1XWidthStart + oBox1XWidthCenter * 6, oBox1YHeight)
'Start the scaling of each view in sheet one to be smaller than the quadrant of the bounding box.
'Using height, and width of the views, we can compare that to a variable established to represent the size of the quadrant they're within.
Dim Page1MaxViewWidth As Double = oPage1BoxWidth / 4 ' Should equal 8.091
Dim Page1MaxViewHeight As Double = oPage1BoxHeight 'Should be the same as the total height of the box, no reason to equate it.
'MessageBox.Show("OUTSIDE LOOP - Page one width: " & oPageOneView1.Width.ToString & " Page one height: " & oPageOneView1.Height.ToString & vbCrLf & " Page 1 width maximum: " & Page1MaxViewWidth & " Page 1 height maximum: " & Page1MaxViewHeight)
Do While oPageOneView1.Width > Page1MaxViewWidth Or oPageOneView1.Height > Page1MaxViewHeight
'
MessageBox.Show("Page one width: " & oPageOneView1.Width.ToString & " Page one height: " & oPageOneView1.Height.ToString & vbCrLf & " Page 1 width maximum: " & Page1MaxViewWidth & " Page 1 height maximum: " & Page1MaxViewHeight)
oPageOneView1.Scale = oPageOneView1.Scale * .96
oPageOneView2.Scale = oPageOneView1.Scale
oPageOneView3.Scale = oPageOneView1.Scale
oPageOneView4.Scale = oPageOneView1.Scale
oPage1.Update
oDoc.Update
'End If
Loop
The Rescaling of the view objects will always fail to be applied upon the thirds iteration. Then because the scale isn't being reduced the while loop will always enter giving me an endless state. I wanted this loop to remove 4-5% of the view scale per iteration until the size is under the maximums set by my box2d object.
Is there some kind of limitation to the number of scales you can apply? I've even changed the loop to have an iIndex that goes up to 5. No matter what It will fail to scale at the third iteration.
Placing first Loop in this text, the other iterations messagebox will be in the attachments
Solved! Go to Solution.