Skip to content

EMSUSD-3563: Add new reference workflow implementation#4591

Open
antonkhelou wants to merge 2 commits into
devfrom
kheloua/dev/EMSUSD-3653_add_reference_with_def_workflow
Open

EMSUSD-3563: Add new reference workflow implementation#4591
antonkhelou wants to merge 2 commits into
devfrom
kheloua/dev/EMSUSD-3653_add_reference_with_def_workflow

Conversation

@antonkhelou
Copy link
Copy Markdown
Collaborator

Changes the existing "Add..." to "Add to Prim...", and adds a new "Add..." menu option under Reference which creates a new prim using the type of the referenced usd file's default prim type, and adds the "reference" arc there.


// Derive the new prim name from the referenced filename stem.
std::string stem = path;
const size_t slash = stem.find_last_of("/\\");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should that cover \ and /. , maybe use the filesystem util maya-usd uses?

if (dot != std::string::npos)
stem = stem.substr(0, dot);
std::string newPrimName = TfMakeValidIdentifier(stem);
if (newPrimName.empty())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that even possible? TfMakeValidIdentifier can return an empty string? probably not

std::string newPrimName = TfMakeValidIdentifier(stem);
if (newPrimName.empty())
newPrimName = "Reference";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont you need to check for name conflicts?

SdfPrimSpecHandle primSpec
= layer->GetPrimAtPath(SdfPath("/" + defaultPrimName));
if (primSpec)
newPrimType = primSpec->GetTypeName().GetString();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and if there's no default prim in there what happens, it explodes?

if (_newPrimType == "Class") {
newPrim = stage->CreateClassPrim(childPath);
} else {
TfToken typeToken = _newPrimType.empty() ? TfToken() : TfToken(_newPrimType);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont htink empty type is a good default


UsdPrim newPrim;
if (_newPrimType == "Class") {
newPrim = stage->CreateClassPrim(childPath);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that a real workflow, to reference a class prim into a new class prim? seems weird. Having a default class prim seems weird as well, dunno what that means

return;
}

const SdfPath refPrimPath = _primPath.empty() ? SdfPath() : SdfPath(_primPath);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume below here is like the add reference command? Would it not be simpler to just have a composite command and reuse the add reference command we already have?

: public UsdUndoableCommand<Ufe::UndoableCommand>
{
public:
UsdUndoAddReferenceToNewPrimCommand(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other add ref command is exposed to python

using This = UsdUfe::UsdUndoAddReferenceCommand;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful if only for tests :

cmd = usdUfe.AddReferenceCommand(prim, refFile, True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants