Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I get the item ID from a selected entity in a sketch?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
m.s.peglar
463 Views, 2 Replies

How do I get the item ID from a selected entity in a sketch?

Hi everyone,

 

I'm trying to get the coords of the start point of a user selected line inside a sketch. I have managed to get the entity and test that it is a line, but how do I then get the line ID of the entity so i can get the coords?

I *think* it might be something to do with cast but I really can't work it out!

 

thanks in advance!

 

Ptr<Selection> selection1 = ui->activeSelections()->item(0);
Ptr<Base> selectedEnt1 = selection1->entity();

if (selectedEnt1->objectType() != LINE_TYPE) {
  ui->messageBox("Selected entities are not sketch lines.");
  return false;
}

int ID = *HOW DO I GET THIS?*
Ptr <Point3D> p0 = lines->item(ID)->startSketchPoint()->worldGeometry();
double x = p0->x();
double y = p0->y();
double z = p0->z();

Labels (2)
2 REPLIES 2
Message 2 of 3
nnikbin
in reply to: m.s.peglar

Hi @m.s.peglar 

You are right, one solution is casting. You can use the automatic casting performed by the Ptr template and you do not need any ID.

 

Ptr<SketchLine> sketchLine = Ptr<SketchLine>(selectedEnt1);
Ptr<Point3D> p0 = sketchLine->worldGeometry()->startPoint();

 

Here in Object Types and Casting section you can find useful relevant information.

Message 3 of 3
m.s.peglar
in reply to: nnikbin

You couldn't have answered better! Thanks for your help again Navid! It's really very appreciated 🙂

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report