Jump to content

Is there a way to redefine a saved view matrix via the SDK?


Recommended Posts

Posted (edited)

We want to update the matrix of a saved view of perspective type. In the UI this is handled via "Redefine..." in the Navigation palette and also allows you to change some restore options but those are not relevant for us.

 

I don't see any methods in the SDK that would allows us to do this. There is gSDK->EditSavedViewWithUI but that opens the Edit dialog, which does not update the matrix, only the other options and the name. A way to trigger to open up the Redefine UI would also be fine for us.

 

"Redefine..." seems update the matrix on the saveViewNode. Would it be possible to directly modify these fields with our new matrix?

 

image.thumb.png.666c29d881245a7c65820f1bd0554558.png

Edited by JHangstoerfer
Link to comment
On 5/9/2022 at 5:50 PM, Maarten DE said:

Since you know where the matrix is located in the aux list, you should be able to adjust it using the aux functions: https://developer.vectorworks.net/index.php/Category:VCOM:VectorWorks:ISDK(Auxiliary_and_Data_Objects)

 

I thought I had some code where I adjusted something in an aux list, but I can't find it anymore...

 

 

I don't see a way to read or write the fields from my screenshot directly. It might be possible they are additionally saved in tagged user data but I don't have the dataTags and dataIndex to read those values without brute forcing to find them.

Link to comment
On 5/11/2022 at 10:04 AM, JHangstoerfer said:

It might be possible they are additionally saved in tagged user data but I don't have the dataTags and dataIndex to read those values without brute forcing to find them.


There is some tagged data below saveViewNode but nothing looks like the information that we want.

Link to comment
  • 3 weeks later...
  • Vectorworks, Inc Employee

virtual GSHandle VCOM_CALLTYPE ViewCreateCurrent() = 0;

virtual void VCOM_CALLTYPE ViewDelete(GSHandle hView) = 0;

virtual GSHandle VCOM_CALLTYPE ViewDuplicate(GSHandle hView) = 0;

virtual size_t VCOM_CALLTYPE ViewGetNumLayers(GSHandle hView) = 0;

virtual void VCOM_CALLTYPE ViewGetLayerVisibility(GSHandle hView, size_t index, InternalIndex& outName, short& outVisibility) = 0;

virtual size_t VCOM_CALLTYPE ViewGetNumClasses(GSHandle hView) = 0;

virtual void VCOM_CALLTYPE ViewGetClassVisibility(GSHandle hView, size_t index, InternalIndex& outClassID, short& outVisibility) = 0;

virtual void VCOM_CALLTYPE ViewStore(GSHandle hView) = 0;

virtual void VCOM_CALLTYPE ViewRestore(GSHandle hView) = 0;

 

@JHangstoerfer ViewStore saves the current layer's view state to the view handle you pass to it.  So if you have the handle you want, then set view projection with gSDK->SetProjection

 and other view settings using other gSDK routines, then call ViewStore that should commit your new changes to the view handle.

 

There is also a utility class VWViewObj that calls these gSDK routines to do the same things.

 

 

Link to comment
23 hours ago, Dave Donley said:

 

@JHangstoerfer ViewStore saves the current layer's view state to the view handle you pass to it.  So if you have the handle you want, then set view projection with gSDK->SetProjection

 

 and other view settings using other gSDK routines, then call ViewStore that should commit your new changes to the view handle.

 

There is also a utility class VWViewObj that calls these gSDK routines to do the same things.

 

gSDK->ViewStore is the call that we needed. The problem was that we used the VWViewObj utility class. In its constructor, it creates a duplicate of the original saved view so VWViewObj::StoreView doesn't actually commit those changes to the correct object.

 

Here is a working sample, although this might required a RestoreView beforehand, otherwise ViewStore commits changes other than the ViewMatrix. At least I think that's how it works.

auto viewParentHandle = VWFC::VWObject::GetNamedObject("Saved View Name");
auto viewHandle = gSDK->FindAuxObject(viewParentHandle, saveViewNode);
auto activeLayer = gSDK->GetActiveLayer();

gSDK->SetViewMatrix(activeLayer, viewMatrix);
gSDK->ViewStore(viewHandle);

 

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...