Jump to content
Developer Wiki and Function Reference Links ×

Scripts to prep drawing for Export to Web View


Recommended Posts

This should probably be a feature request.  But until then I'm working on two scripts to prep a drawing to export to a web view.

 

I'm posting two simple scripts that I've started using.  They are just down and dirty at the moment.  If anyone else is going through this workflow and has any ideas, I'd love to hear about other ways of doing this.

 

First:  Web View is pretty amazing.  And I'm assuming it will continue to improve.  (Lighting ?)

 

But if the client uses a mobile phone or tablet to view the model in first person mode it's important to make sure the doors are open.  Of course, the doors can't be open in section views.  And the open angle convention in top/plan for some of my client's offices is 30 or 45 for swing doors.  Sliders and pocket doors sometimes have different open angles.  Before exporting to web view I want to set 3D Open on all the doors to TRUE and set the doors to at least a 90° open angle.

 

Then after the export, I want to set 3D Open on all the doors to FALSE and return them to their previous angles.

 

Here's what I'm playing with now:  Just the basics.

 

BEFORE exporting to web view…

 

PROCEDURE OpenTheDoor;

{14 April 2017}
{Badly scripted by Michael Klaers}

{This script preps the doors in a drawing to be ready to 'Export Web View'
It preserves the 3D Open boolean and the open angle of each door in User Field 9 and 10
and then sets the 3DOpen to TRUE and the Open Angle to 90°}

{There is a companion script that restores the doors to their original state}

VAR
	
	ShouldILeaveThisOpen	: STRING;
	OriginalOpenAngle  		: STRING;	
	
{------------------------------------------------------------Record & Open Procedure}	
	
PROCEDURE RecordAndOpen(h : HANDLE);
	BEGIN


		ShouldILeaveThisOpen := GetRField(h,'Door','3DOpen');
		OriginalOpenAngle := GetRField(h,'Door','OpenAngle');
		SetRField(h,'Door','UserFld9',OriginalOpenAngle);	
		SetRField(h,'Door','UserFld10',ShouldILeaveThisOpen);
		SetRField(h,'Door','OpenAngle','90');
		SetRField(h,'Door','3DOpen','TRUE');
		ResetObject(h);

	END;

{-----------------------------------------------------------------------Main Program}	

BEGIN

ForEachObject(RecordAndOpen,(((R IN ['Door']) & ('Door'.'OnSched'=TRUE))));

END;


RUN(OpenTheDoor);



 

AFTER exporting to web view:

PROCEDURE CloseTheDangDoor;

{14 April 2017}
{Badly scripted by Michael Klaers}

{This script restores the doors in a drawing after 'Export Web View'
It recalls the 3D Open boolean and the open angle of each door from User Field 9 and 10
and then restores the 3DOpen Boolean and the Open Angle to their original values}

{There is a companion script that records original state of the doors.  Run than one first.}

VAR
	OriginalOpenAngle  		: STRING;	
	ShouldILeaveThisOpen	: STRING;


{------------------------------------------------------------Read & Restore Procedure}	

PROCEDURE WereYouBornInABarn(h : HANDLE);

	BEGIN

		OriginalOpenAngle := GetRField(h,'Door','UserFld9');	
		ShouldILeaveThisOpen := GetRField(h,'Door','UserFld10');
		SetRField(h,'Door','OpenAngle',OriginalOpenAngle);
		SetRField(h,'Door','3DOpen',ShouldILeaveThisOpen);
		ResetObject(h);
	
	END;

{----------------------------------------------------------------------Main Program}	

BEGIN

ForEachObject(WereYouBornInABarn,(((R IN ['Door']) & ('Door'.'OnSched'=TRUE))));

END;


RUN(CloseTheDangDoor);




 

Right now it only selects doors that are on schedule.  That way it doesn't mess with cased openings, etc.  

 

Probably need to filter out demo doors in remodel projects (filter by class in criteria?).  Or maybe just let them open and close.  They're on a layers/classes that are invisible to the web view export.  No harm, no foul.?

 

I'm thinking there has to be a way to set some doors to open to 180 and some to open to 90°.  Maybe check a different user field for a value other than 90 and IF/THEN the open value.  Or open sliders and pocket 90° and others 180°?

 

Scripting question:  If I don't want to use user fields, is there a way - other than creating and attaching a new record format to each door - to preserve the data?  I'll probably end up doing that anyway, but if there's another way…

 

If anyone else is using web view, give these a try.  Let me know if you have any suggestions.

 

mk

 

 

Scripts Set Doors for Web View Export.vwx

Link to comment

Other than a custom (preferably hidden) record format, the other option that I can think of would be to assign a UUID to the name field of each object and then write a text or XML file with the original information on each object. When restoring, iterate through the file to find the UUID and access the data you need.

 

Both options are kind of bad.

 

Sorry.

Link to comment

I've never tried writing an XML file.  And I won't for this script.  But is there a standard place to put that file?

 

I think the next step is to put a logic test on the door swing.  Open sliders, pockets, bifold, and double acting doors to 90°, open swing and bipart swings to 180° unless…  

 

…unless there is a value in another user field or there is a way to figure out if the wall containing the door has a T join or L join on the side the door opens toward that is closer than the width of the leaf or leaves.

 

I bet it's going to be another user field.

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...