iLogic Change drawing borders from assembly

iLogic Change drawing borders from assembly

Anonymous
Not applicable
2,702 Views
4 Replies
Message 1 of 5

iLogic Change drawing borders from assembly

Anonymous
Not applicable

I have an external rule that opens all parts in an assembly and performs a series of tasks to these parts. One task is to print the drawing for the part, if there is one. I would like to add the task of changing the border of the drawing. I can get a rule to accomplish this with one single drawing open. But I need to be able to go through all drawings associated to all the parts in an assembly. Here is a small example of one of the code variations I have used to try and accomplish this, it just will not work. Any help would be very much welcomed.

 

Dim oDrawDoc As DrawingDocument
oDrawDoc=ThisApplication.Documents.Open(idwPathName, True)
oDrawDoc.Activate
oDrawDoc=ThisApplication.ActiveDocument

Try
oDrawDoc.ResourceFileName="L:\Inventor\file.idw"
oDrawDoc.ActiveSheet.SetBorder("border", "", "")
Catch
EndTry
0 Likes
Accepted solutions (1)
2,703 Views
4 Replies
Replies (4)
Message 2 of 5

Vladimir.Ananyev
Alumni
Alumni

Your code does not work because it mixes Inventor API code with iLogic function  SetBorder.

Inventor API requires first delete the current border and only then add new one using existing border definition.

The following iLogic function does both operations - deletes the old border and adds new one using BorderDefinition "NewBorder":

ActiveSheet.Border = "NewBorder"

  

VB version:

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
'reference to the active sheet
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
'delete current border on the active sheet
Dim oBorder As Border = oSheet.Border
oBorder.Delete
 
'add new border. BorderDefinition name  "NewBorder"
Dim oBorderDef As BorderDefinition = oDrawDoc.BorderDefinitions.Item("NewBorder")
oSheet.AddBorder(oBorderDef)

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank you for your response Vladimir. I still have an issue though. I probably was not very clear before. The border I need does not exist in the drawings that are being changed. That is why I have the code in there to change the resource file name. This part of the code does not work. If there is a better way to do it I am open for suggestions. Thank you again for your help.

 

Steve

0 Likes
Message 4 of 5

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

I believe BorderDefinition.CopyTo method could be useful for you:

BorderDefinition.CopyTo( TargetDocument As DrawingDocument, [ReplaceExisting] As Boolean ) As BorderDefinition

It copies border definition from one drawing document to another.

The same approach but for TitleBlocks was described here:

http://adndevblog.typepad.com/manufacturing/2012/10/copy-title-block-from-one-drawing-to-a-new-drawi...


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

Anonymous
Not applicable

Thank you Vladimir. This idea seems to work well.

0 Likes