Constraining Sketch Point or Work Plane to Assembly's Center of Gravity with iLogic

Constraining Sketch Point or Work Plane to Assembly's Center of Gravity with iLogic

danielcLJDRZ
Explorer Explorer
1,018 Views
11 Replies
Message 1 of 12

Constraining Sketch Point or Work Plane to Assembly's Center of Gravity with iLogic

danielcLJDRZ
Explorer
Explorer

I've been working on an assembly and I'm facing some difficulties. My objective is to constrain a component's sketch point or work plane to the assembly's center of gravity (CoG). Despite trying various methods, I haven't been successful.

I was wondering if this task could be accomplished using iLogic? I'm relatively new to iLogic, so any guidance on this would be incredibly helpful.

Here's what I've attempted so far:

  1. Determining the Center of Gravity: Using the "Center of Gravity" command, I can visualize the CoG of the assembly. However, utilizing this point directly for constraints has proven to be challenging.

  2. Reference Geometry Creation: I tried creating reference geometry (such as a work point or work plane) at the CoG. While I can create these references, constraining my component’s sketch point or work plane to these references hasn't yielded the desired results.

Is there a way to leverage iLogic to simplify this process? If so, a step-by-step explanation or any example codes would be immensely valuable.

0 Likes
Accepted solutions (3)
1,019 Views
11 Replies
Replies (11)
Message 2 of 12

bradeneuropeArthur
Mentor
Mentor

Could you share a component that needs to be constraint in the assembly, the assembly file is not needed in this case?

Could you also give me the sketchpoint you need to use?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 12

danielcLJDRZ
Explorer
Explorer

I'm trying to constrain the sketch point center of the 6.010 rectangle to the CoG.

0 Likes
Message 4 of 12

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Here you have a piece of code that created a UCS at the center of Gravity (Center Of Mass).

Herewith you can constraint the component....

Sub main
  
    Dim oDoc As AssemblyDocument = ThisAssembly.Document

    Dim oCompDef As AssemblyComponentDefinition
    oCompDef = oDoc.ComponentDefinition
	
    Dim acg As MassProperties = oCompDef.MassProperties
    Dim p As Point = acg.CenterOfMass

    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry

    Dim oMatrix As Matrix
    oMatrix = oTG.CreateMatrix

    Dim oTranslationMatrix As Matrix
    oTranslationMatrix = oTG.CreateMatrix
    Call oTranslationMatrix.SetTranslation(oTG.CreateVector(p.X, p.Y, p.Z))

    Call oMatrix.TransformBy(oTranslationMatrix)

    Dim oUCSDef As UserCoordinateSystemDefinition
    oUCSDef = oCompDef.UserCoordinateSystems.CreateDefinition

    oUCSDef.Transformation = oMatrix

    Dim oUCS As UserCoordinateSystem
    oUCS = oCompDef.UserCoordinateSystems.Add(oUCSDef)
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 5 of 12

danielcLJDRZ
Explorer
Explorer

Thank you so much!!

Message 6 of 12

bradeneuropeArthur
Mentor
Mentor

Appreciated...

Let me know if I can do something else for you.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 7 of 12

danielcLJDRZ
Explorer
Explorer

Is there a way to have the UCS update when the CoG changes?

0 Likes
Message 8 of 12

bradeneuropeArthur
Mentor
Mentor
Accepted solution

sure:

 

Sub main
    ' Create a new part document
    Dim oDoc As AssemblyDocument = ThisAssembly.Document

    Dim oCompDef As AssemblyComponentDefinition
    oCompDef = oDoc.ComponentDefinition
	
	Dim acg As MassProperties = oCompDef.MassProperties
	Dim p As Point = acg.CenterOfMass

    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry

    ' Create an identity matrix
    Dim oMatrix As Matrix
    oMatrix = oTG.CreateMatrix

    Dim oTranslationMatrix As Matrix
    oTranslationMatrix = oTG.CreateMatrix
    Call oTranslationMatrix.SetTranslation(oTG.CreateVector(p.X, p.Y, p.Z))

    Call oMatrix.TransformBy(oTranslationMatrix)

    ' Create an empty definition object
    Dim oUCSDef As UserCoordinateSystemDefinition
    oUCSDef = oCompDef.UserCoordinateSystems.CreateDefinition

    oUCSDef.Transformation = oMatrix

    Dim oUCS As UserCoordinateSystem
	
	Try
		
	oUCS = oCompDef.UserCoordinateSystems.Item("UCS_COG")
	oUCS.Transformation = oMatrix
	
	Catch
	oUCS = oCompDef.UserCoordinateSystems.Add(oUCSDef)
	oUCS.Name = "UCS_COG"	
		
End Try
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 12

bradeneuropeArthur
Mentor
Mentor

I think now you are asking me, it is better to create a add-in for Inventor because you could use the Events better.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 10 of 12

danielcLJDRZ
Explorer
Explorer

How do I create an add-in to achieve this update?

0 Likes
Message 11 of 12

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Are you a bit familiar with Vb.net?

For now you can also add the rule to the save Event found in the Ilogic Event Triggers...

bradeneuropeArthur_1-1715977964749.png

 

bradeneuropeArthur_0-1715977920307.png

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 12 of 12

danielcLJDRZ
Explorer
Explorer

Hi Arthur,

 

I'm not very familiar with VB.NET. Could you please provide some guidance or resources on how to add the CG auto-update rule to the save event using the iLogic Event Triggers?

 

Thanks,

Dan

0 Likes