iLogic Place Parts List Top Left of Border

iLogic Place Parts List Top Left of Border

Anonymous
Not applicable
2,147 Views
5 Replies
Message 1 of 6

iLogic Place Parts List Top Left of Border

Anonymous
Not applicable

Goal:

I am trying to use iLogic to insert a parts list, prompt user for parts list style, and position the parts list to the top left.

 

Problem:

I can use a static 2d point to position the parts list, but because the style can be changed, the size typically also changes and then the table ends up hanging off to the left of the sheet  - since the reference point for the parts list is to the top right. In the code below I am attempting to first create the parts list positioned at the Border.RangeBox.MinPoint (essentially 0,0), and then reposition it using Border.RangeBox.MaxPoint.Y (the top of the border) and offsetting the table in the X direction by PartsList.RangeBox.MaxPoint.X (the overall width of the table). This results in the table being positioned correctly in the Y direction, but the X offset isn't right. This tells me that either PartsList.RangeBox.MaxPoint.X isn't actually representing the overall width of the table, or I am doing something else wrong here.

 

Can someone with more knowledge in iLogic than myself take a look at the code and help me out? Thanks!

 

Sub Main()

'Declare local variables
Dim oDrawDoc As DrawingDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView
Dim oPlacementPoint As Point2d
Dim oPartsList As PartsList 
Dim oBorder As Border
Dim oStyle As String
Dim oPlaceX As Double
Dim oPlaceY As Double

'initialize variables
oDrawDoc = ThisApplication.ActiveDocument
oSheet = oDrawDoc.ActiveSheet
oDrawingView = oSheet.DrawingViews(1)
oBorder = oSheet.Border

'user input - select parts list style
oStyle = InputListBox("Choose Parts List Style", MultiValue.List("PartsListStyle"), "Custom Parts List (ANSI)", "Parts List Style", "List Prompt") 

'create parts list
oPartsList = oSheet.PartsLists.Add(oDrawingView, oBorder.RangeBox.MinPoint)
oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item(oStyle)

'reposition parts list to top left
oPlaceX = oBorder.RangeBox.MinPoint.X + oPartsList.RangeBox.MaxPoint.x
oPlaceY = oBorder.RangeBox.MaxPoint.Y
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX,oPlaceY)
oPartslist.position = oPlacementPoint

End Sub
0 Likes
Accepted solutions (1)
2,148 Views
5 Replies
Replies (5)
Message 2 of 6

BrandonBG
Collaborator
Collaborator

You're close. Try this change:

 

oPlaceX = oBorder.RangeBox.MinPoint.X
oPlaceY = oBorder.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MaxPoint.Y

Top left corner of the border means the X coordinate is the same as the border (left).  To get the correct Y coordinate, you need to subtract the height of the parts list.

 

BrandonBG

0 Likes
Message 3 of 6

Anonymous
Not applicable

Brandon, no the reference point for the parts list table is to the top right. In other words, if you position the table at (0,0), the top right of the table will be coincident with the bottom left of the sheet (see picture below). So positioning the Y value at oBorder.RangeBox.MaxPoint.Y (top of the border), correctly positions the top of the table to the top of border.

 

As I said, it is the X offset that isnt working correctly. When I try to use +oPartsList.RangeBox.MaxPoint.X, it only moves to the right by like an inch or so, rather than all the way over to where the left side of the table is coincident with the left side of the border (see other picture below). And in fact as you can see in that picture, when I ouput oPartsList.RangeBox.MaxPoint.X to a message box, I get a goofy result (1.9304). So I think the issue is with the method I'm trying to retrieve the overall width of the table(?)

 

Located at (0,0)

Located at 0-0.JPG

 

 

Located at:

oPlaceX = oBorder.RangeBox.MinPoint.X + oPartsList.RangeBox.MaxPoint.X

oPlaceY = oBorder.RangeBox.MaxPoint.Y

Offset.JPG

0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor
Yes, it is your method.

RangeBox uses the box WITH RESPECT to the SHEET ORIGIN. Thus, as your PartsList moves, so will the location it puts it in.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 6

BrandonBG
Collaborator
Collaborator
Accepted solution

You're correct about the position of the Parts List.

 

I think you need to calculate the size of the Parts List, then move it.

 

oPlaceX = oBorder.RangeBox.MinPoint.X + [width of parts list]

oPlaceY = oBorder.RangeBox.MaxPoint.Y

 

Giving you:

 

oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)

oPlaceY = oBorder.RangeBox.MaxPoint.Y

 

BrandonBG

 

 

Message 6 of 6

Anonymous
Not applicable

Thanks Brandon, that was the kick to the tire that got the engine started!

 

Mech, thank you for the explanation! That makes total sense now.

0 Likes