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: 

Surface Pattern

2 REPLIES 2
Reply
Message 1 of 3
MarksBarfieldArchitects
1245 Views, 2 Replies

Surface Pattern

Hello,

 

I have recently dumped Digital Project (Catia mod for architecture design) by adopting Inventor for a series of reasons, Revit compatibility, support, costs, etc, and I am truly enjoying Inventor so far. Easy to learn specially if you are coming from Digital Project and even though I am finding easier than DP to find information from different sources i.e. help files and google info is not so readily available when you compare to some other parametric packages, mainly Grasshopper for Rhino3D. 

 

Anyways, one of the features I miss the most in Inventor  is to be able to pattern a surface, similar to the misleading 'rectangular' pattern where we can actually use a curve as a guide, but actually using a survace's UV values to lay your pattern on. I love Inventor and the lack of this feature is somewhat a buzzkill, maybe it is due to my lack of knowledge or maybe it is a feature that is only available on sheet metal design? I was only able to find how to produce holes based on a 2D pattern using Grills but this does not help me to achieve what I am looking for, therefore forcing me to dive straight into scripting. Now I am wondering if I am trying to reinvent the wheel by coding this, and if this is not the case, seek advice from you, the community, on what is the best way to move forward with what I am doing.

 

Even though I've managed to write a quick code yesterday that creates points based on a UV pattern, and knowing that the object browser is an amazing source of info, it will take me a while to understand and get used with the best practices around. TLDR I am asking you guys to help me out by giving me some pointers, places where I can find relevant info or guidelines to what I would like to do as listed below:

 

1 - How do I create and add attributes to a point so it recognizes its position as dependent of a SurfaceEvaluator value? If this is possible it would enable to this pattern of points to recognize when the guide surface changed and reposition which would be helpful with iCopies I think.

 

2 - How do I reference external parameters on a script? That way I could change the number of rows and columns in the pattern.

 

3 - I am yet to fully understand how an iCopy works but would it be possible to cluster these points into an 'entity' where using iCopy it would recognize that the pattern cluster has changed and readapt by changing sizes and number of components?

 

Please find below the code I wrote yesterday as it may help someone trying to achieve the same as well as screengrabs:

 

Type of part I'm trying to achieve:

 

Type of part I'm trying to achieve

 

Surface Patterning with points:

 

be2d643bbac60c1e06c0a16ae322fc23.png

 

 

 

Public Sub SurfaceGeometry()

Dim DivU As Integer
Dim DivV As Integer

DivU = 20 'To be replaced by parameter.
DivV = 40 'To be replaced by parameter.

'Get the active document.
Dim oParDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

' Set a reference to the component definition.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition

'Get the surface.
On Error Resume Next
Dim oFace As Face
Set oFace = oPartDoc.SelectSet.Item(1)
If Err Then
 MsgBox "A face must be selected."
 Exit Sub
End If
On Error GoTo 0

'Get the surface evaluator from this surface.
Dim oSurfEval As SurfaceEvaluator
Set oSurfEval = oFace.Evaluator

'Get the parametric range of the surface.
Dim oParamRange As Box2d
Set oParamRange = oSurfEval.ParamRangeRect

'Get minimum and maximum surface parameters.
Dim minUPar As Double
Dim maxUPar As Double
Dim minVPar As Double
Dim maxVPar As Double

minUPar = oParamRange.MinPoint.X
maxUPar = oParamRange.MaxPoint.X

minVPar = oParamRange.MinPoint.Y
maxVPar = oParamRange.MaxPoint.Y

'Define increment values
Dim stepU As Double
Dim stepV As Double

stepU = (maxUPar - minUPar) / DivU
stepV = (maxVPar - minVPar) / DivV


'Get Transient Geometry to draw points.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry

'Draw Points on Surface
Dim i As Integer
Dim j As Integer
For i = 1 To (DivU + 1)
    For j = 1 To (DivV + 1)
    
        Dim U As Double, V As Double
        
        If i = 1 Then
        U = minUPar
        ElseIf i <> 1 Then
        U = (i - 1) * stepU
        End If
        
        If j = 1 Then
        V = minVPar
        ElseIf j <> 1 Then
        V = (j - 1) * stepV
        End If
               
        Dim adParamCoord(1) As Double
        adParamCoord(0) = U
        adParamCoord(1) = V
        
        Dim adPoint(2) As Double
        Call oSurfEval.GetPointAtParam(adParamCoord, adPoint)
        
        Dim oWP As WorkPoint
        Set oWP = oCompDef.WorkPoints.AddFixed(oTransGeom.CreatePoint(adPoint(0), adPoint(1), adPoint(2)))
        
          
    Next
Next


End Sub

 

2 REPLIES 2
Message 2 of 3

Hi Guilherme,

 

Unfortunately what you are looking for is not easily doable, as you already found out. The API doesn't provide enough granularity to fire a notification when a specific surface has changed. You would need to listen to higher level events. For example "PartEvents.OnSurfaceBodyChanged" can be used to detect a modification of a body has occurred in the document. Another suggestion would be to use "ModelingEvents.OnFeatureChange" if you know exactly which feature(s) are generating the surface you want to use for the pattern.

 

A good starting point is to use the "Event Watcher", a tool provided along with the Inventor SDK. Take a look in the Developer Tools. This toll allows you to monitor the output of various events, so you can get a better idea without writting much code yourself.

 

So to better address your questions:

 

1/ and 3/ are not directly possible the way you expose it, you would need to use existing events at a higher level to detect a change has occured to the surface you are using.

 

2/ You can create user parameters that you can access from the API. Take a look at the API Help Files sample: "Creating a new parameter group API Sample".

 

I hope it helps,

Philippe.

 

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

I am creating a tool to aliviate this issue precisely, maybe we can collaborate. 

 

bravaiser

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

Post to forums  

Autodesk Design & Make Report