Jump to content
Sign in to follow this  
redl

Dynamic clipping

Recommended Posts

Hello,

Much like clipping masks in illustrator, I'd like to have a dynamic clipping object which would consist in :

- a set of objects (base)

- a clipping path (mask)

And which would display the part of the objects that are inside the clipping path.

It would have exactly the same result than the "clip tool", except that the base objects would remain untouched. This would allow to clip some complex objects (for instance thick dashed lines) without loosing their parametric aspect.

Does this already exist ?

If it does not, is it possible to make such a plugin using a Path-type plugin object ? (I'm quite new to VS, so I'm not sure of its capabilities). What do you think ? Is it worth investigating ?

Thanks !

Share this post


Link to post

I did not think of using a viewport...

However, it seems that you need a Designer license to be able to put a viewport on a design layer, and I think that even in this case you would need to create a dedicated layer for the content you want to crop (which can quickly lead to an over-complex document).

I'd just like to be able to clip the content of a group. I'm currently trying to code this, and I've already some interesting results. But it's still heavily buggy. Be careful if you try it, i crashed VectorWorks several times.

I joined what what I've got this far.

To use it, you put the clipping path in the path, and the clipping content in section of the custom path object.

ubbthreads.php?ubb=download&Number=5856&filename=clipping%20example.png

Edited by redl

Share this post


Link to post

Design Layer Viewports are a feature of Architect, Landmark, Spotlight and Designer. It does not exist in Fundamentals. Fundamentals has Layer Links instead, but these cannot be cropped.

Share this post


Link to post

Ok. But isn't using a viewport for such a simple thing a bit clumsy, especially if you have to crop several elements on several places in your document ?

Here's the script I got so far (unchanged since last post). Does someone know why it is "flickering" ? (the clipping is very unaccurate and changes on every recalculation)

Thanks !



PROCEDURE ClippingMask;

VAR
plugN: STRING;
plugH, recordH, wallH, profileH, pathH: HANDLE;
vertexNum, vertexType, I: INTEGER;
H, pX, pY,  arcRadius: REAL;
handleToObject,otherHandle,voidHandle : HANDLE;
dX, dY, dZ :REAL;

{THOSE VARS ARE USED TO GET THE PARAMETERS}
show_path: BOOLEAN;
show_clip: BOOLEAN;

{THOSE VARS ARE USED FOR ATTRIBUTE COPY}
source, target: HANDLE;
r, g, b : LONGINT;
temp_b : BOOLEAN;
temp_i : INTEGER;

	BEGIN
		show_path	:= PSHOW_PATH;
		show_clip	:= PSHOW_CLIP;

		IF GetCustomObjectInfo (plugN, plugH, recordH, wallH) THEN
			BEGIN

				pathH := GetCustomObjectPath(plugH);
				profileH := GetCustomObjectProfileGroup(plugH);

				{GET THE ORIGIN OF THE PLUGIN OBJECT}
				GetSymLoc3D(plugH,dX,dY,dZ);


				handleToObject:=FInGroup(profileH);
			WHILE handleToObject <> NIL DO BEGIN

					otherHandle := ConvertToPolygon(handleToObject, 64);

				vertexNum := GetVertNum(otherHandle);

					FOR I := 1 TO vertexNum DO
				BEGIN
					GetPolylineVertex(otherHandle, I, pX, pY, vertexType, arcRadius);
					{WE MOVE THE POLY POINTS BY THE PATH's POSITION SO THAT THE PROFILE ELEMENTS STAY AT THE SAME ABSOLUTE POSITION}
					SetPolyPt(otherHandle, I,pX-dX, pY-dY);
				END;

				voidHandle := ClipPolygon(otherHandle, pathH, 1.0);

				{BEGIN ATTRIBUTE COPY, source:http://www.vectorlab.info/index.php?title=Attr-Attributes_copy}
				source := otherHandle;
				target := voidHandle;
				IF (target <> NIL) & (source <> NIL) THEN
				BEGIN
					SetClass(target, GetClass(source));
					IF IsLSByClass(source) THEN
						SetLSByClass(target)
					ELSE
						SetLS(target, GetLS(source));
					IF IsLWByClass(source) THEN
						SetLWByClass(target)
					ELSE
						SetLW(target, GetLW(source)); 
					IF IsPenColorByClass(source) THEN
					SetPenColorByClass(target)
					ELSE
					BEGIN
						GetPenFore(source, r, g, b);
						SetPenFore(target, r, g, b);
						GetPenBack(source, r, g, b);
						SetPenBack(target, r, g, b);
					END;
					IF IsFPatByClass(source) THEN
						SetFPatByClass(target)
					ELSE
						SetFPat(target, GetFPat(source));
					IF IsFillColorByClass(source) THEN
						SetFillColorByClass(target)
					ELSE
					BEGIN
						GetFillFore(source, r, g, b);
						SetFillFore(target, r, g, b);
						GetFillBack(source, r, g, b);
						SetFillBack(target, r, g, b);
					END;
					GetOpacityByClass(source, temp_b);
					IF temp_b = TRUE THEN
						SetOpacityByClass(target)
					ELSE
					BEGIN
						GetOpacity(source, temp_i);
						SetOpacity(target, temp_i);
					END;
				END;
				{END ATTRIBUTE COPY}


				IF show_clip=false THEN
				BEGIN
					{WE HIDE THAT BY SETTING ATTRIBUTES (could also delete them)}
					vertexNum := GetVertNum(pathH);
						SetLS(source,0);
						SetLW(source, 0); 
						SetPenFore(source,0,0,0);
						SetPenBack(source,0,0,0);
					SetFPat(source, 0);
					SetFillFore(source, 0, 0, 0);
					SetFillFore(source, 0, 0, 0);
					SetOpacity(source, 0);
					END;

					SetSelect(source);
					MoveBack;


				handleToObject:=NextObj(handleToObject);
			END;


			DSelectAll;


			IF show_path THEN
			BEGIN
				vertexNum := GetVertNum(pathH);

					BeginPoly;
						FOR I := 1 TO vertexNum DO
					BEGIN
						GetPolylineVertex(pathH, I, pX, pY, vertexType, arcRadius);
						AddPoint(pX, pY);
					END;
				EndPoly;
				END;

			END;


	END;

Run(ClippingMask);

Share this post


Link to post
Am I the only one to think it's worth investigating ?

I just can't see for what you will use this. Maybe you can give some more examples? Because for every clipping, you need to use different source objects and I got a feeling that this clipping is just to show different pieces of one group. The idea is nice though.

Share this post


Link to post

Possible uses :

- complex pavings (so you could still change the global shape of the paving because you wouldn't need to trim it)

- regular layouts (you could have a regular layout of parkings lots or furniture to adapt to a surface, eventually with an option to hide partially trimmed objects)

- clipping complex objects (for now, there is no way to hide some parts of a complex object (symbol, PIO, ...) without having to convert it to polygons, which makes it loose it's parametric quality).

More globally, the most interesting aspect of a clipping path is that you can move/scale/rotate the content independently from the boundaries.

In Photoshop they are called masks, in Illustrator clipping path, in Indesign it's the frames...

They really are very useful ! I don't know why they don't make them in CAD software...

Share this post


Link to post
Possible uses :

- complex pavings (so you could still change the global shape of the paving because you wouldn't need to trim it)

I think this is better done with the new tile fill that was introduced in VW2011. I really like it and use it a lot. I used it for all ground covers and for 2D elevations. You can make the repeating part as big as you like and have color variation in them, very nice! Also, you can set the rotation, origin and scale of it. The shape you use it on is the clipping.

Possible uses :

- regular layouts (you could have a regular layout of parkings lots or furniture to adapt to a surface, eventually with an option to hide partially trimmed objects)

There are tools in VW for creating parking lots. And as far as I know, you don't want furniture to adapt to a surface. If you mean a seating layout, that's also in VW. You can even use your own symbols with the seating layout!

Possible uses :

- clipping complex objects (for now, there is no way to hide some parts of a complex object (symbol, PIO, ...) without having to convert it to polygons, which makes it loose it's parametric quality).

Well, if you want to hide a part, that's useally because something is above it, so you just draw the thing above and you will not see the part. You can use the stack order of the objects to create this effect. It's not like drawing in the old days where you cut off all you don't see, just draw what's there, set the stack order and it will be ok.

Don't get me wrong, I don't want discourage you. It's just that I know what it is to make things and then find out that there is actually ways of doing it in the program. Sometimes, you just have to look and think out of the box. So if there are specific things that you want to be done, let us know and other can tell you how they do it. I find such things really interesting because other can learn new ways.

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