SDK:Parametric Hide Details

From Vectorworks Developer
Jump to navigation Jump to search

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

By Vladislav Stanev

What's that

Parametric object is like a container of VectorWorks objects. When rendering the parametric object, VectorWorks will draw the content (the inner objects inside the parametric) of the parametric object.

Hiding details allows the plug-in, that regenerates the content of the parametric, to control if each inner object should be drawn inside the parametric or not depending on the layer scale or viewport scale in which the parametric exist.

This will allow the plug-in to mark some of the inner objects so they don't appear if the layer scale of viewport scale is less than specified threshold or appear if the layer scale is above that threshold.

Rules

The following rules are established for detailing.

Each plug-in (which describes parametric type) defines one threshold (N) for all parametric instances of that type.

Flags

  • ovHideDetail -- object is to be hidden when showing details (looking close in the drawing)
  • ovHideNonDetail -- object is to be hidden when showing general (non-details) (looking the drawing from away)

If the current layer scale or viewport scale, there are the following situations:

Note: Objects without any of those flags attached are always drawn.

Setting up

To enable "Hide Details" for that parametric type your parametric plug-in should have SDK:Parametric Extended Properties enabled.

The parametric extension must setup the extended properties and enable "Hide Details". To do that you have to set the following extended properties: kObjXPropCustomHideFactor

Note that the extended properties are manipulated though a VCOM (VectorWorks Component Object Model) interface IExtendedProps part of Category:VCOM:VectorWorks:PluginSupport.

The threshold is set as double value. The value specified is treated as 1:<value> scale threshold:

  • 1:1 -- value = 1.0
  • 1:2 -- value = 2.0
  • 2:1 -- value = 0.5
  • and so on

Note Value 0 of kObjXPropCustomHideFactor property is error situation and is considered as 1.

EObjectEvent CObjParametricObj_EventSink::OnInitXProperties(CodeRefID objectID)
{
    // obtain the interfact for accessing the extended properties
    using namespace VectorWorks::Extension;
    VCOMPtr<IExtendedProps>    extProps( IID_ExtendedProps );

    // All parametric objects of this type will have the threshold set here
    extProps->SetObjectProperty(objectID, kObjXPropCustomHideFactor, double(2));

    return kObjectEventNoErr;
}

Create inner objects

When creating inner objects in the parametric during the Recalculate event. See SDK:Parametric General Info#Extension Class Implementation.

To demonstrate, create tree lines. The first one is normal, the second is marked with ovHideDetail, and the third one with ovHideNonDetail.

EObjectEvent CObjParametricObj_EventSink::Recalculate()
{
    MCObjectHandle	hLine1	= ::GS_CreateLine( gCBP, WorldPt(0,0), WorldPt(0,100) );
    MCObjectHandle	hLine2	= ::GS_CreateLine( gCBP, WorldPt(30,0), WorldPt(30,100) );
    MCObjectHandle	hLine3	= ::GS_CreateLine( gCBP, WorldPt(60,0), WorldPt(60,100) );

    gSDK->SetObjectVariable( hLine2, ovHideDetail, TVariableBlock( (Boolean) true ));
    gSDK->SetObjectVariable( hLine3, ovHideNonDetail, TVariableBlock( (Boolean) true ) );

The result object looks like this:

1. When the layer scale is 1:1 -- greater than the example's threshold (1:2).

Drawing ovHideDetail objects. See the rules above.
So the example object, the first line is drawn because it doesn't have flags set; and the second line is drawn because it is marked with ovHideDetail.

2. When the layer scale is 1:4 -- less than the example's threshold (1:2).

Drawing ovHideNonDetail objects. See the rules above.
So the example object, the first line is drawn because it doesn't have flags set; and the third line is drawn because it is marked with ovHideNonDetail.

See also

SDK:Plug-in Object Events | SDK:Parametric Object Plug-in