Make an opened document the active doument

Make an opened document the active doument

harvey_craig2RCUH
Advocate Advocate
436 Views
2 Replies
Message 1 of 3

Make an opened document the active doument

harvey_craig2RCUH
Advocate
Advocate

I have created a simple example demonstrating a drawing rule that opens the referenced part, activates it then changes a parameter.

Dim oDrawing As Document = ThisApplication.ActiveDocument
Dim oPartPath As String = oDrawing.ReferencedDocuments.Item(1).FullFileName
Dim oPart As PartDocument = ThisApplication.Documents.Open(oPartPath, True)
oPart.Activate()
Parameter("Length") = 20
oPart.Save
oPart.Close(True)

The problem is, the activate line doesn't appear to do anything because it gets error, when attempting to change the parameter:

harvey_craig2RCUH_0-1736246284723.png

This parameter definitely exists in the part. Where have I gone wrong? I've attached the example.

 

Thanks,

Harvey

0 Likes
Accepted solutions (2)
437 Views
2 Replies
Replies (2)
Message 2 of 3

marcin_otręba
Advisor
Advisor
Accepted solution

hi,

Using parameter(" ")=.. means that it will be parameter from document in wchich you ran the rule.

 

try this instead:

 

Dim oDrawing As Document = ThisApplication.ActiveDocument
Dim oPart As PartDocument = oDrawing.ReferencedDocuments(1)
oPart.ComponentDefinition.Parameters("Length").Expression = 20 ' or oPart.ComponentDefinition.Parameters("Length").value= 20
oPart.Update
oDrawing.Update

 

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 3

g.georgiades
Advocate
Advocate
Accepted solution

You can specify the document name using the Parmeter command

See https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=3dfb2e63-5750-d8a2-6d5c-5ae6bb99b9f9

 

I believe DisplayName is what is needed, you could also try the InternalName if this doesn't work.

 

Parameter(oPart.DisplayName,"Length") = 20

 

0 Likes