Controlling Manage>Insert>Import with iLogic

Controlling Manage>Insert>Import with iLogic

will_roe
Enthusiast Enthusiast
328 Views
1 Reply
Message 1 of 2

Controlling Manage>Insert>Import with iLogic

will_roe
Enthusiast
Enthusiast

Hi,

 

Is there anyway to either automating the process Manage>Insert>Import when importing a .dwg in as far as it importing off a list of filepaths into a .ipt or replacing an already imported .dwg with another file?

 

I've already got the below.

'(ThisApplication.CommandManager.ControlDefinitions(”ControlDefinitionName”).Execute)'

CreateDwgUnderlayCmd

AppImportFileCmd

0 Likes
Accepted solutions (1)
329 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor
Accepted solution

The most basic iLogic rule would look like this.

Dim dwgFileName = "C:\Path\to\your.dwg"

Dim oDoc As PartDocument = ThisDoc.Document

Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oRefComponents As ReferenceComponents = oCompDef.ReferenceComponents

Dim oImportedDWGDef As ImportedDWGComponentDefinition = oRefComponents.ImportedComponents.CreateDefinition(dwgFileName)

Dim oImportedComponent As ImportedComponent = oRefComponents.ImportedComponents.Add(oImportedDWGDef)

This will place the dwg at the origin of your part. It will not be constrained to a face. Automatically constraining the dwg is difficult. but there is a workaround that might work for you.

Just run the rule and when it is finished you can redefine the location. That will constrain the dwg to a face.

JelteDeJong_0-1715806239198.png

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes