Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hello everyone!
I am trying to create a rectangle of four lines using OTK Java. This will be a section for my extrusion. All lines for the extrusion must be coincident. But I don’t know how to make them like that.
Because of this, it is not possible to extrude.
My code is:
Point2Ds tops = Point2Ds.create();
Point2D A = wfcSession.CreatePoint2D(90.00,90.00);
Point2D B = wfcSession.CreatePoint2D(90.00,-90.00);
Point2D C = wfcSession.CreatePoint2D(-90.00,-90.00);
Point2D D = wfcSession.CreatePoint2D(-90.00,90.00);
Point2D E = wfcSession.CreatePoint2D(90.00,90.00);
tops.set(0, A); tops.set(1, B); tops.set(2, C); tops.set(3, D); tops.set(4, E);
SectionEntityPolyline rectangle = wfcSection.SectionEntityPolyline_Create(tops);
SectionEntity entity = (SectionEntity)rectangle;
sketch.AddEntity(entity);
Section that is obtained after starting:
Please help, if anyone knows.
Thanks in advance.
Regards!
Solved! Go to Solution.
In toolkit examples (UgCreoSweepCreate.c) I found this piece of code
ProError UgSweepAppAddRectangle (ProSection nsketch,int offset)
{
Pro2dLinedef rect_entity1,rect_entity2,rect_entity3,rect_entity4;
int ent_id=0;
rect_entity1.type = PRO_2D_LINE;
rect_entity1.end1[0] = -50 + (-offset);
rect_entity1.end1[1] = 40 + offset;
rect_entity1.end2[0] = 50 + offset;
rect_entity1.end2[1] = 40 + offset;
rect_entity2.type = PRO_2D_LINE;
rect_entity2.end1[0] = 50 + offset;
rect_entity2.end1[1] = 40 + offset;
rect_entity2.end2[0] = 50 + offset;
rect_entity2.end2[1] = -40 + (-offset);
rect_entity3.type = PRO_2D_LINE;
rect_entity3.end1[0] = 50 + offset;
rect_entity3.end1[1] = -40 + (-offset);
rect_entity3.end2[0] = -50 + (-offset);
rect_entity3.end2[1] = -40 + (-offset);
rect_entity4.type = PRO_2D_LINE;
rect_entity4.end1[0] = -50 + (-offset);
rect_entity4.end1[1] = -40 + (-offset);
rect_entity4.end2[0] = -50 + (-offset);
rect_entity4.end2[1] = 40 + offset;
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity1),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity2),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity3),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity4),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionIntentManagerModeSet(nsketch, PRO_B_TRUE);
sweep_create_log("ProSectionIntentManagerModeSet ");
status = ProSectionIntentManagerModeSet(nsketch, PRO_B_FALSE);
sweep_create_log("ProSectionIntentManagerModeSet ");
return;
}
Try to use something like this
Point2Ds tops = Point2Ds.create();
Point2D A = wfcSession.CreatePoint2D(90.00,90.00);
Point2D B = wfcSession.CreatePoint2D(90.00,-90.00);
Point2D C = wfcSession.CreatePoint2D(-90.00,-90.00);
Point2D D = wfcSession.CreatePoint2D(-90.00,90.00);
Point2D E = wfcSession.CreatePoint2D(90.00,90.00);
tops.set(0, A); tops.set(1, B); tops.set(2, C); tops.set(3, D); tops.set(4, E);
SectionEntityPolyline rectangle = wfcSection.SectionEntityPolyline_Create(tops);
SectionEntity entity = (SectionEntity)rectangle;
sketch.AddEntity(entity);
// ADD
sketch.SetIntentManagerMode(true);
sketch.SetIntentManagerMode(false);
Hello,
I believe that the trick is SetIntentManagerMode()
sketch.SetIntentManagerMode(true); // magic ON
Point2D center = wfcSession.CreatePoint2D(0.00,0.00);
SectionEntityCircle circle = wfcSection.SectionEntityCircle_Create(center,300.00);
SectionEntity entity = (SectionEntity)circle;
sketch.AddEntity(entity);
circle = wfcSection.SectionEntityCircle_Create(center,20.00);
entity = (SectionEntity)circle;
sketch.AddEntity(entity);
sketch.SetIntentManagerMode(false); // magic OFF
Thanks for the answer!
Yes, I understand that I need to enable ManagerMode.
I already did that and everything worked with the round section.
Now I want to create a part with a rectangular section, but I can’t draw such a section.
Best Regards!
In toolkit examples (UgCreoSweepCreate.c) I found this piece of code
ProError UgSweepAppAddRectangle (ProSection nsketch,int offset)
{
Pro2dLinedef rect_entity1,rect_entity2,rect_entity3,rect_entity4;
int ent_id=0;
rect_entity1.type = PRO_2D_LINE;
rect_entity1.end1[0] = -50 + (-offset);
rect_entity1.end1[1] = 40 + offset;
rect_entity1.end2[0] = 50 + offset;
rect_entity1.end2[1] = 40 + offset;
rect_entity2.type = PRO_2D_LINE;
rect_entity2.end1[0] = 50 + offset;
rect_entity2.end1[1] = 40 + offset;
rect_entity2.end2[0] = 50 + offset;
rect_entity2.end2[1] = -40 + (-offset);
rect_entity3.type = PRO_2D_LINE;
rect_entity3.end1[0] = 50 + offset;
rect_entity3.end1[1] = -40 + (-offset);
rect_entity3.end2[0] = -50 + (-offset);
rect_entity3.end2[1] = -40 + (-offset);
rect_entity4.type = PRO_2D_LINE;
rect_entity4.end1[0] = -50 + (-offset);
rect_entity4.end1[1] = -40 + (-offset);
rect_entity4.end2[0] = -50 + (-offset);
rect_entity4.end2[1] = 40 + offset;
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity1),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity2),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity3),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionEntityAdd(nsketch,(Pro2dEntdef*)&(rect_entity4),&ent_id);
sweep_create_log("ProSectionEntityAdd ");
status = ProSectionIntentManagerModeSet(nsketch, PRO_B_TRUE);
sweep_create_log("ProSectionIntentManagerModeSet ");
status = ProSectionIntentManagerModeSet(nsketch, PRO_B_FALSE);
sweep_create_log("ProSectionIntentManagerModeSet ");
return;
}
Try to use something like this
Point2Ds tops = Point2Ds.create();
Point2D A = wfcSession.CreatePoint2D(90.00,90.00);
Point2D B = wfcSession.CreatePoint2D(90.00,-90.00);
Point2D C = wfcSession.CreatePoint2D(-90.00,-90.00);
Point2D D = wfcSession.CreatePoint2D(-90.00,90.00);
Point2D E = wfcSession.CreatePoint2D(90.00,90.00);
tops.set(0, A); tops.set(1, B); tops.set(2, C); tops.set(3, D); tops.set(4, E);
SectionEntityPolyline rectangle = wfcSection.SectionEntityPolyline_Create(tops);
SectionEntity entity = (SectionEntity)rectangle;
sketch.AddEntity(entity);
// ADD
sketch.SetIntentManagerMode(true);
sketch.SetIntentManagerMode(false);
Thank you so much!
It works!
It was not quite obvious to me.
Apparently, if I create in an active ManagerMode, then it perceives each line as a separate object.
And if I first create and then turn on ManagerMode, then it takes the whole section from there, as a single object.
Best Regards!