Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to change the partlist insert point. Upper right point is sucks :-(

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
kbo
Advocate
782 Views, 7 Replies

how to change the partlist insert point. Upper right point is sucks :-(

When i insert a partlist in a drawing the insert point of the partlist is in the upper right corner? i want the insertpoint in the lower right corner, because i know the height of our titleblock. Then i will allways be able to possition the partlist right above the titleblock. I never know how heigh the partlist is because the amount of parts in the partlist is different every time. does anyone know if its possible to change the partlist insertpoint to the lower right corner of the partlist when its inserted via the API?

 

Help please. 

7 REPLIES 7
Message 2 of 8
jdkriek
in reply to: kbo

This will put the Parts List right on top of your title block

 

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet =  oDoc.ActiveSheet
Dim oBorder As Border = oSheet.Border
Dim oPlacementPoint As Point2d
oModelDoc = ThisDrawing.ModelDocument
   
If Not oBorder Is Nothing Then
	oPlacementPoint = oBorder.RangeBox.MaxPoint
Else
	oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)
End If
    
For i = 1 To oSheet.PartsLists.Count
	oSheet.PartsLists.Item(1).Delete
Next i

Dim oPartsList As PartsList
oPartsList = oSheet.PartsLists.Add(oModelDoc, oPlacementPoint)

minXpoint = oSheet.TitleBlock.RangeBox.MinPoint.x
minYpoint = oSheet.TitleBlock.RangeBox.MaxPoint.Y
maxXpoint = oPlacementPoint.x
dPointY = oSheet.PartsLists.Item(1).RangeBox.MinPoint.Y - minYpoint
maxYpoint = oPlacementPoint.Y - dPointY
    
Dim newmin, newmax As Point2d
newmin = ThisApplication.TransientGeometry.CreatePoint2d(minXpoint, minYpoint)
newmax = ThisApplication.TransientGeometry.CreatePoint2d(maxXpoint, maxYpoint)
oSheet.PartsLists.Item(1).Delete
oPartsList = oSheet.PartsLists.Add(oModelDoc, newmax)
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 8
kbo
Advocate
in reply to: kbo

Thanks for this fine / great code example, you saved my day. If you ever come to denmark i will buy you a beer 🙂

 

i had to modify you code a bit but now it work right like i want i to. Again Thanks!

 

Here is what i ended up with i had to add the height of my titleblock.

 

regards Kent boettger

 

 Dim oDrawingView As DrawingView

        oDrawingView = oSheet.DrawingViews(1)

        Dim oPlacementpoint As Point2d
        Dim oPartsList As PartsList
        Dim oBorder As Border = oSheet.Border

        If Not oBorder Is Nothing Then

            oPlacementpoint = oBorder.RangeBox.MaxPoint

        Else

            oPlacementpoint = oApp.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)

        End If

        'Delete old partlist if found
        For i = 1 To oSheet.PartsLists.Count

            oSheet.PartsLists.Item(1).Delete()

        Next

        'add new partlist and calculate placement
        oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementpoint)

        Dim minXpoint As Double = oSheet.TitleBlock.RangeBox.MinPoint.X
        Dim minYPoint As Double = oSheet.TitleBlock.RangeBox.MinPoint.Y
        Dim maxXPoint As Double = oPlacementpoint.X
        Dim dPointY As Double = oSheet.PartsLists.Item(1).RangeBox.MinPoint.Y - minYPoint
        Dim maxYpoint As Double = (oPlacementpoint.Y + 6.3#) - dPointY

        Dim newmin, newmax As Point2d

        newmin = oApp.TransientGeometry.CreatePoint2d(minXpoint, minYPoint)
        newmax = oApp.TransientGeometry.CreatePoint2d(maxXPoint, maxYpoint)

        'Delete the inserted partlist again
        oSheet.PartsLists.Item(1).Delete()

        'Add final partlist.
        oPartsList = oSheet.PartsLists.Add(oDrawingView, newmax)

 

Message 4 of 8
jdkriek
in reply to: kbo

Glad that worked for you.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 8
GosponZ
in reply to: jdkriek

Hi,

on default border working perfect, but on custom border i got error

 

Error on Line 3 : Type 'p534g9_0' is not defined.

 Jonathan can you help?

Thank you

Message 6 of 8
jdkriek
in reply to: GosponZ


@MisterZS wrote:

Hi,

on default border working perfect, but on custom border i got error

 

Error on Line 3 : Type 'p534g9_0' is not defined.

 Jonathan can you help?

Thank you


MisterZS, I tested with a custom border and it works fine on my end. oSheet.Border contains whatever the active border is custom or not on the sheet. The only thing you could perhaps try is setting the active border before you define oBorder. But that was not needed to work for my tests.

 

ActiveSheet.Border = "YourCustomBorderName"
Dim oBorder As Border = oSheet.Border
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 7 of 8
GosponZ
in reply to: jdkriek

I added line of code you suggest but still same error

Error on Line 5 : Type 'p534g9_0' is not defined.

but if i turn off line of code

'Dim oBorder As Border = oSheet.Border it is working but table stick to the sheet size not to the border.


Thank you

Message 8 of 8
GosponZ
in reply to: GosponZ

I think i found problem. Word Border was in blue and that bother me somehow. I switched to lower case and bingo.

I don't know why.

Dim oBorder As Border = oSheet.Border

Dim oBorder As border = oSheet.Border

But here is another question since code working perfect on my machine.

I'm working with multi sheets, and every sheet is with different part. I would like to insert part list table in each sheet  with iproperties for that part. I tried with this one and it is always same table in each sheet.

Is this possible?

Thank you

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report