Jump to content
Sign in to follow this  
michaelk

CreateExtrudeAlongPath surprises

Recommended Posts

UserObject := LSActLayer;

DuplicateUserObject := HDuplicate(UserObject,0,0);

DSelectAll;

SetSelect(DuplicateUserObject);

DoMenuTextByName('Convert to NURBS',0);

DuplicateUserObject := LSActLayer;

DSelectAll;

ArcByCenter(0,0,1.9,0,360);

PipeDiamCircle := LSActLayer;

ThreeDPart := CreateExtrudeAlongPath(DuplicateUserObject,PipeDiamCircle);

DelObject(DuplicateUserObject);

DelObject(PipeDiamCircle);

I'm writing a script to help me (better) understand how to write (better) scripts.

The above script produces results that I find surprising.

1. The extrude along path object is actually 3 nurbs surfaces, rather than one extrude along path solid. What am I doing wrong?

2. Later in the script, when I SetClass(ThreeDPart) only one of the 3D nurbs surfaces is set to that class.

3. Even though I am setting objects to classes - SetClass(handle,class name) with SetClUseGraphic('ClassName',TRUE); the objects are getting the class settings, but not the graphic attributes.

Any thoughts would be appreciated!

mk

Share this post


Link to post

1. You're not doing anything wrong. an extrude along path is always a grouping of nurbs surfaces when made through scripting.

2. It's easier to first set the class so that anything later will be drawn in that class.

3. Same as above, when you first set the class, then draw the objects, this will be ok.

Share this post


Link to post

Michael -

Eehoing what Dieter said...

1) EAP does create multiple objects. Creating them within a Group and using FInGroup, PrevObj, and NextObj will let you get handles to the individual bits.

2) Though Assigning Classes after-the-fact will work, I've not had the best success w. doing so and getting Class Attributes to work w/o constant PIO resets. Before-creation Class setting seems to fix that.

Share this post


Link to post

Try using

MyEAPHandle := CreateCustomObjectPath('Extrude Along Path',MyPathH,MyProfileH);

instead of the EAP.

Pointed out to me (and Andrew and probably others) by Robert Anderson on the Vectorscript list.

Edited by Pat Stanford

Share this post


Link to post

To set the graphic attributes with SetClass, you need to apply it to the profile object(s).

The profile object should also be a group even if it contains only one object.

If you use

CreateCustomObjectPath('Extrude Along Path',MyPathH,MyProfileH);

as Pat suggested and I also use, you do not need to delete the path and profile objects; they become part of the extrude.

To see how an extrude could be coded, draw an extrude manually with classes or any other attributes and then export to vectorscript.

Share this post


Link to post

Pat

I read that. Why does the object need a name (as opposed to just a handle)?

I can't get it to work. I've tried with the second argument a nurbs curve and a line and the 3rd argument circle and a group.

But nothing happens.

What am I doing wrong?

mk

Share this post


Link to post

hrrrmpf, mumble, mumble...

Assigning the class first works in one case and not another...

I end up with one object in the correct class, but attributes are not by class.

The other object(s) are in the correct class with attributes by class.

Another minor thing or two:

1. If the script is run by double clicking in the RB, then an escape X is required to get out of the RB and get to the selection tool (if not already selected). This does not happen when double clicking a script from the open script palette.

Is there a way to script "escape" or return to the drawing?

2. Often (maybe always) when the script is run, the only way to select the main "EAP" nurbs surface(s) is to switch to a 3D view. Even switching to a 3D view and back to Top/Plan is sufficient to make it selectable.

Does the script leave VW or the object in a weird state?

I'm running this in 2011 Designer on a Mac.

Thanks all for your patience and insight. I'll attach the script. I appreciate any comments / suggestions.

mk

PS There are a lot of extra setClass() commands. Just trying different options to get the class attributes to apply...

Share this post


Link to post

Why does the object need a name (as opposed to just a handle)?

You can create different types of path objects, including your own path pio's, which are defined by name in the active workspace.

 
FUNCTION DrawPipe(className: STRING; pipeDia,pipeThk: REAL; begPt,endPt: VECTOR): HANDLE;
VAR
midPt: VECTOR;
outerRad,innerRad: REAL;
outerHdl,innerHdl,profHdl,pathHdl,pipeHdl: HANDLE;
BEGIN
outerRad:= pipeDia / 2;
innerRad:= outerRad - pipeThk;

{Create group profile object}
BeginGroup;
ArcByCenter(0,0,outerRad,#0d,#360d);
outerHdl:= LNewObj;
IF pipeThk > 0 THEN
	BEGIN
	ArcByCenter(0,0,innerRad,#0d,#360d);
	innerHdl:= LNewObj;
	IF NOT AddHole(outerHdl,innerHdl) THEN
		WriteLn('Could not add hole');
	DelObject(innerHdl);
	END;
EndGroup;
SetClass(outerHdl,className);
profHdl:= LNewObj;

midPt.x:= (begPt.x + endPt.x) / 2;
midPt.y:= (begPt.y + endPt.y) / 2;
midPt.z:= (begPt.z + endPt.z) / 2;

{Create nurbs line path object}
pathHdl:= CreateNurbsCurve(begPt.x,begPt.y,begPt.z,TRUE,1);
IF pathHdl <> NIL THEN
BEGIN
AddVertex3D(pathHdl,midPt.x,midPt.y,midPt.z);
AddVertex3D(pathHdl,endPt.x,endPt.y,endPt.z);
NurbsSetWeight(pathHdl,0,0,1);
NurbsSetWeight(pathHdl,0,1,1);

NurbsSetKnot(pathHdl,0,0,0);
NurbsSetKnot(pathHdl,0,1,0);
NurbsSetKnot(pathHdl,0,2,1);
NurbsSetKnot(pathHdl,0,3,1);
END
ELSE
WriteLn('Could not create path');

pipeHdl:= CreateCustomObjectPath('Extrude Along Path', pathHdl, profHdl);
IF (pipeHdl <> NIL) THEN
BEGIN
SetRField(pipeHdl,'Extrude Along Path', 'Scale', 'Uniform');
SetRField(pipeHdl,'Extrude Along Path','Factor','1');
SetClass(pipeHdl,className);
END;
DrawPipe:= pipeHdl;
END;

This function will draw a linear pipe

Share this post


Link to post

Thanks, Miguel. I'm finally getting time to pick it apart...

I get why a very simple nurbs curve - a straight line - needs a weight for each vertex. But why does it need 4 Knots?

I'm not totally clear what a Knot is.

...and finally.... is WriteLn writing a message to an external file not specified in this snippet of script?

Thanks again

MK

Share this post


Link to post

But why does it need 4 Knots?

I am not very clear on this either. I do know that the knots are created with the nurbs curve and setting them to those values ensures it is a straight line. BTW the nurbs code was copied from exporting VS.

WriteLn writing a message to an external file not specified in this snippet of script?

When a file is not open for writing, these calls go to the Output.txt file and VS errors to the ErrorOut.txt file in your user folder. Since you have to drill down many folders to get to them, I have links on the desktop for easy access.

Share this post


Link to post

hmmmm

It appears that nurbs curves (and surfaces?) are divided by knot vectors.

The number of knots = number of control points + degree of nurbs curve + 1.

The knot vectors determine how much influence each control point has on nearby parts of the curve.

Making the first two knots identical insures that the first control point has 100% control (so the curve dead ends at that point) over the beginning of the curve. Ditto with the last two knots and the end of the curve.

Nice discussions of nurbs curves here:

http://www.mactech.com/articles/develop/issue_25/schneider.html

http://www.rhino3d.com/nurbs.htm

______________

Besides Message() and alert or dialog boxes, what other ways are there to write in VS? Is it possible, for example, to write to the space at the bottom left of the screen where tool information usually lives?

_____________________

I should really get back to work....

thanks again

mk

Share this post


Link to post

Besides Message() and alert or dialog boxes, what other ways are there to write in VS? Is it possible, for example, to write to the space at the bottom left of the screen where tool information usually lives?

PROCEDURE AlertInform(text:STRING; advice:STRING; minorAlert:BOOLEAN);

with minorAlert = TRUE, it will display the message on the status bar.

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...