Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

How to create manual tabs for a 2D contour

billostratum
Advocate Advocate
585 Views
6 Replies
Message 1 of 7

How to create manual tabs for a 2D contour

billostratum
Advocate
Advocate

I'm trying to programmatically create tabs for a 2D Contour. I haven't found any advice in the documentation as to how to go about this.

 

I started with this;

 

 

operation.parameters.itemByName('group_tabs').value.value = True
operation.parameters.itemByName('tabPositions').value.value = [point3d, point3d, point3d, point3d]

 

 

The first line works, but I can't find the proper format for the second line. Everything I've tried gives me a generic "parameter error".

 

I have Point3D's available that are guaranteed to be on the Profile that is the source of the chain inputGeometry.

 

I know this is not a full example, but does someone know what type of value is expected by this parameter? If I use the UI to select points, it lets me select any random point and the Select field shows that I selected a Point. That would indicate to me the tabPositions parameter is expecting a list of points.

 

Thanks,

Bill

billoStratum
Reply
Reply
0 Likes
Accepted solutions (1)
586 Views
6 Replies
Replies (6)
Message 2 of 7

billostratum
Advocate
Advocate

Additional info.

 

I created a manual tab in the UI and then inspected the tabPositions parameter value.

 

The value is: 

<adsk.cam.CadObjectParameterValue; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::cam::CadObjectParameterValue > *' at 0x0000014F89C777B0> >

 

I never know how to dig deeper once I see a Swig proxy.

billoStratum
Reply
Reply
0 Likes
Message 3 of 7

Jorge_Jaramillo
Collaborator
Collaborator

hi,

 

You don't have to care about the Swig's proxy (it makes reference as how it is implemented internally).

You have to deal with the object type, which is a adsk.cam.CadObjectParameterValue:

Jorge_Jaramillo_0-1719964863463.png

 

So, in this case, use its value property to discovery the objects it references.

 

I hope this can help.

 

Regards,

Jorge

 

Reply
Reply
0 Likes
Message 4 of 7

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

Hi,

 

The following snippet works for me:

 

des: adsk.fusion.Design = app.activeDocument.products.itemByProductType('DesignProductType')
cam: adsk.cam.CAM = app.activeDocument.products.itemByProductType("CAMProductType")
contour2D = cam.setups[0].operations[0]

poss_list = [des.rootComponent.sketches[0].sketchPoints[i] for i in range(5,9)]
contour2D.parameters.itemByName("group_tabs").value.value = True
contour2D.parameters.itemByName("tabPositions").value.value = poss_list

 

 

Take into account that the tabPositions array expects SketchPoint's instead of Point3D's objects.

In the example I'm using sketch points 5th to 8th defined in the sketch.

 

This is the result once I run it:

Before:

Jorge_Jaramillo_0-1719971739590.png

 

After:

Jorge_Jaramillo_1-1719971822643.png

 

 

Regards,

Jorge Jaramillo

 

Reply
Reply
2 Likes
Message 5 of 7

billostratum
Advocate
Advocate

The value of the CadObjectParameterValue is another swig proxy

<adsk.core.BaseVector; proxy of <Swig Object of type 'std::vector< adsk::core::Ptr< adsk::core::Base > > *' at 0x0000014F89CC9F20> >

  This sounds like it's related to a Vector, but it has no properties (other than thisOwn).

billoStratum
Reply
Reply
0 Likes
Message 6 of 7

billostratum
Advocate
Advocate

Thanks. That's exactly what I was looking for.

 

I'll give that a try. I have to get my points as SketchPoint's somehow. Right now I have SketchCircle's and I am using their centroids.

 

Bill

billoStratum
Reply
Reply
0 Likes
Message 7 of 7

billostratum
Advocate
Advocate

To complete the thought, here is my completed snippet:

	_tabCircles = sketch.sketchCurves # all curves in the tab sketch are circles
	_tabCenters = [c.centerSketchPoint for c in _tabCircles]

	camOp.parameters.itemByName('group_tabs').value.value = True
	camOp.parameters.itemByName('tabPositions').value.value = _tabCenters
	camOp.parameters.itemByName('tabWidth').value.value = _tabDiameter
	camOp.parameters.itemByName('tabHeight').value.value = _tabHeight
	camOp.parameters.itemByName('tabPositioning').value.value = 'tabCount'
	camOp.parameters.itemByName('tabsPerContour').value.value = 0
billoStratum
Reply
Reply
1 Like