Jump to content
Developer Wiki and Function Reference Links ×

Plugin Obj chimes every time...why?


LarryO

Recommended Posts

Does anyone know why my script chimes every time it is selected from the tool sets, every instance at placement and anytime I use one of the pop-up selections?

I originally wrote this for VW2013 but other than the chiming it works fine in VW2019.

 

PROCEDURE Wedgie_Anchor;

VAR
Bool1:BOOLEAN;
TempI1:INTEGER;
LongI1,LongI2:LONGINT;
BoltLength,ShaftRadius,ShaftLength,ThreadLength,rSlot,rHeight,NutThickness,WasherThickness,
DocUPI,SelectPtX1,SelectPtY1,SelectPtX2,SelectPtY2,RingThickness,rETBN:REAL;
Units2Mark,UnitsMark,PIO_Name:STRING;
PIO_Handle,PIO_Record,PIO_ParentWall,ObjHandle,hWasher,hNut:HANDLE;
ar3BoltSize:ARRAY[1..3]OF CHAR;
TempArray:ARRAY[1..16]OF CHAR;
TempDynArray:DYNARRAY[]OF CHAR;

BEGIN
{Parameter Visibility}
Bool1:=GetCustomObjectInfo(PIO_Name,PIO_Handle,PIO_Record,PIO_ParentWall);
IF PAnchorSize='Custom' THEN BEGIN
    SetParameterVisibility(PIO_Handle,'BDiameter', TRUE);
    SetParameterVisibility(PIO_Handle,'OALength', TRUE); END
ELSE BEGIN
    SetParameterVisibility(PIO_Handle,'BDiameter', FALSE);
    SetParameterVisibility(PIO_Handle,'OALength', FALSE); END;

{PushAttrs;}

GetUnits(LongI1,LongI2,TempI1,DocUPI,UnitsMark,Units2Mark);

ar3BoltSize:=PAnchorSize;

IF ('3/8'=ar3BoltSize) | ('1/2'=ar3BoltSize)
    THEN WasherThickness:=1.6mm  {1.6mm = 3/8" & 1/2" Narrow washer thickness}
    ELSE WasherThickness:=2.5mm; {2.5mm = 5/8", 3/4" & 1" Narrow washer thickness}

RingThickness:=((Str2Num(ar3BoltSize)*8)-1)*0.5mm;

BoltLength:=POALength;

{Extra Thread Beyound Nut - rETBN}
rETBN:=WasherThickness+DocUPI*Str2Num(ar3BoltSize)*1.5;
{BOLT DIAMETER formula is DocUPI*Str2Num(ar3BoltSize)}
ShaftRadius:=DocUPI*Str2Num(ar3BoltSize)/2;

TempArray:=PAnchorSize;
TempDynArray:=TempArray;


Delete(TempDynArray,1,6);
TempI1:=Pos('"',TempDynArray);
Delete(TempDynArray,TempI1,TempI1);
BoltLength:=DocUPI*(Str2Num(Copy(TempDynArray,1,TempI1)));

IF PAnchorSize='Custom' THEN BEGIN
rETBN:=PBDiameter*1.5;
ShaftRadius:=PBDiameter/2;
BoltLength:=POALength;
END;

{formula for expansion portion is ratio from Ø3/8" anchor which is 1" Long to Ø5/8" anchor which is 1.5" Long}
ThreadLength:=BoltLength-25.4mm-2*(ShaftRadius*2-9.525mm);

ShaftLength:=Boltlength-ThreadLength;

Locus(0,0); {Orgin indicator}

{Threaded end}
OpenPoly;
BeginPoly;
AddPoint((-ShaftRadius+0.53mm),3.175mm);
AddPoint((-ShaftRadius+0.53mm),0.0);
AddPoint(-ShaftRadius,0.0);
AddPoint(-ShaftRadius,-ThreadLength+3.175mm);
AddPoint((-ShaftRadius+1.95385mm),(-ThreadLength));
AddPoint((ShaftRadius-1.95385mm),(-ThreadLength));
AddPoint(ShaftRadius,-ThreadLength+3.175mm);
AddPoint(ShaftRadius,0.0);
AddPoint((ShaftRadius-0.53mm),0.0);
AddPoint((ShaftRadius-0.53mm),3.175mm);
EndPoly;
ObjHandle:=LNewObj;
HMove(ObjHandle,0.0,ThreadLength-rETBN);

{Threads}
MoveTo((-ShaftRadius+0.53mm),ThreadLength-rETBN);
LineTo((ShaftRadius-0.53mm),ThreadLength-rETBN);
MoveTo(-ShaftRadius,3.175mm-rETBN);
LineTo(ShaftRadius,3.175mm-rETBN);

{The following 2 lines are drawn as hidden lines}
PushAttrs;LSByClass;LWByClass;PenColorByClass;NameClass('Pen_0.13-Hidden');
MoveTo(-ShaftRadius+1.06mm,4mm-rETBN-2.58375mm);
LineTo(-ShaftRadius+1.06mm,ThreadLength-rETBN);
MoveTo(ShaftRadius-1.06mm,4mm-rETBN-2.58375mm);
LineTo(ShaftRadius-1.06mm,ThreadLength-rETBN);
PopAttrs;

{Tapered end}
BeginPoly;
AddPoint(-ShaftRadius+3/64",3.175mm);
AddPoint(-ShaftRadius+1/64",BoltLength-(ThreadLength+1mm));
AddPoint(ShaftRadius-1/64",BoltLength-(ThreadLength+1mm));
AddPoint(ShaftRadius-3/64",3.175mm);
EndPoly;
ObjHandle:=LNewObj;
HMove(ObjHandle,0.0,ThreadLength+RingThickness-rETBN);

{Begin Expansion Collar}

rSlot:=((ShaftRadius*16)-1)/64; {1/2 SLOT WIDTH}
rHeight:=ShaftRadius+9.525mm; {Overall height of Collar}
IF ShaftRadius<=4.7625mm THEN rHeight:=rHeight-3.175mm;

{Bumps on Expansion Collar}
ArcByCenter(ShaftRadius-3.175mm, rHeight/2+ThreadLength+RingThickness*2+3.175mm-rETBN, 3.969mm, 323.13, 73.74);
ArcByCenter(-ShaftRadius+3.175mm, rHeight/2+ThreadLength+RingThickness*2+3.175mm-rETBN, 3.969mm, 143.13, 73.74);

PushAttrs;FillPat(1);
ClosePoly;
BeginPoly;
AddPoint(-ShaftRadius,0.0);
AddPoint(-ShaftRadius,rHeight);
AddPoint(-rSlot,rHeight);
ArcTo(-rSlot,rHeight/2,0);
AddPoint(0.0,rHeight/2);
ArcTo(rSlot,rHeight/2,0);
AddPoint(rSlot,rHeight);
Addpoint(ShaftRadius,rHeight);
Addpoint(ShaftRadius,0.0);
AddPoint(rSlot,0.0);
ArcTo(rSlot,rSlot,0);
AddPoint(0.0,rSlot);
ArcTo(-rSlot,rSlot,0);
AddPoint(-rSlot,0.0);
EndPoly;
ObjHandle:=LNewObj;
HMove(ObjHandle,0.0,ThreadLength+RingThickness*2+3.175mm-rETBN);
PopAttrs;
{End Expansion Collar}

{Draw Expansion Stop Ring}
Rect(-ShaftRadius,ThreadLength+3.175mm-rETBN,ShaftRadius,ThreadLength+3.175mm-rETBN+RingThickness);

{Draw Washer}
PushAttrs;FillPat(1);
hWasher:=CreateCustomObjectN('Plain Washer (Inch)',0.0,-WasherThickness,0.0,FALSE);
SetRField(hWasher,'Plain Washer (Inch)','series','Type B - Narrow');
{SetRField(hWasher,'Plain Washer (Inch)','size',ar3BoltSize);}
SetRField(hWasher,'Plain Washer (Inch)','size', Num2Str(3,2*ShaftRadius/DocUPI));
SetRField(hWasher,'Plain Washer (Inch)','view','Front');
SetRField(hWasher,'Plain Washer (Inch)','showCL','FALSE');
PopAttrs;
{End Washer}

{Draw Nut}
PushAttrs;FillPat(1);
hNut:=CreateCustomObjectN('Nut (Inch)',0.0,WasherThickness,0.0,FALSE);
SetRField(hNut,'Nut (Inch)','typeIndex','Hex Nut - Heavy');
SetRField(hNut,'Nut (Inch)','size',Num2Str(3,2*ShaftRadius/DocUPI));
SetRField(hNut,'Nut (Inch)','view','Front');
SetRField(hNut,'Nut (Inch)','showCL','FALSE');
Hrotate(hNut,0.0,0.0,180d);
PopAttrs;
{End Nut}

{PopAttrs;}
END;

{Larry Osolin 2013, not for resale and or redistribution without credit and written approval please.}
RUN(Wedgie_Anchor);

Capture1.JPG

Link to comment

Larry,

   The code you wrote from scratch is not beeping, but you call two built-in PIO's at the end of your script and access their "Size" parameters (as shown in the OIP) using "size" as the parameter name. This is the wrong parameter name. 

 

   When you access a parameter from a PIO, VS always uses the name in the left hand column of he Plug-In Manager, but the OIP always displays the name from the Alternate Name column when it exists. This can be confusing if the names are the same as they are in this case. The "Size" parameter from the OIP which in this case is the Alternate Name for the parameter, belongs to "size_1", which is the actual parameter name for both Built-In PIO's.

 

   To access the "Size" parameter in both of these PIO, you need to use the "size_1" parameter name. It is parameter #2 in the Plain Washer (Inch) PIO, where you are accessing parameter #7 "size". In the Nut (Inch) PIO, the "Size" parameter  is again #2, "size_1", where you are accessing parameter #22 "size". The real clue comes when you look at both parameter lists using the Plug-In Editor and the alternate name for both parameters named "size" is "__NNA_DO_NOT_CHANGE".

 

   I don't know if you opened either of these plugins in the Plug-In Manager, but if you haven't, do so. This description may make a lot more sense.

 

   Bottom line – you are accessing parameters in Built-In Plugins that should not be changed; hence the beep.

 

HTH,

Raymond

  • Like 1
Link to comment

Thanks Guys,

With your insight I have found the issue.

 

Raymond, you were almost right. I'm not sure exactly how NNA does this but the first parameter chooses which list of values to display when the user activates the pull down (that part is easy) (example: regular hex nut = make visible and display the values in size_1, heavy hex nut = make visible and display the values in __size_2 and so on) but they then seem to somehow transfer that directly to the 'size' parameter. Their plugin only responds to values entered into the 'size' parameter. My bad it turns out is that I am replacing the "size" parameter with a decimal equivalent of the fractional value. ie: '0.625' instead of '5/8'. The latter seems to be what their script expects but somehow that didn't kill the script. It chimed instead and then possibly converted it to a real again internally and finished its task. The "__NNA_DO_NOT_CHANGE" I believe is NNA's way of saying to the various distributors to not localize the name into the regional language.

I made a number of attempts to use those other parameters early on by hard coding in different values like '3/4' etc but their plugin script does not seem to check upon the value stored in those various parameters that hold the value lists, even after issuing a ResetObject().

It looks like I'm going to have to create a clumsy case statement to match up decimal values to fractional representation to shut the thing up. This is what makes all of this fun, isn't that right!? 😂

 

PS: Then again maybe not, I already have those in the initial selection process

Edited by LarryO
Link to comment

I don't know if this will help or not, but back in 2007 I wrote a similar script to add washers and nuts to the JBolt object. I have not tested it recently, but here it is if you want to take a look at what I did. It used the built in JBolt, Nut, and Washer objects. I needed up needing to add a custom text file including the various parameters for the PIO objects.

 

Ask if you have questions, but this is from a long time ago.

 

The Unencrypted is the script. The _inch is the data file for the objects.

 

Danj-BoltAndNut_inch.txt Danj_Bolt (Unecrypted).txt

Link to comment

Looks interesting Pat, and admittedly much clearer organization than mine, hehehe.

You allowed the user the ability to move the washer and nut but I couldn't find if there was a limiter in there to ensure the minimum two threads above the nut.

Myself I have (for now) foregone entering the whole table matching thread count to bolt diameter and simply approximate the amount that must extend above the nut. I'm about 3mm over on 1" size and almost true at 1/4" size. Some day I may become inspired and work some more on this but for now I happy that today I have filled in all the size gaps up to 1" in 1/8" increments. I wasn't aware of the full size range when I began this wedge anchor until after I had hard coded the use of the first three characters to represent the diameter. Our shop doesn't use 5/16" and the engineer's in the area use epoxied rod more often than not for 1" and over. The other aspect with imperial stuff is that many times the sizes are nominal, which is possibly the case for the lengths associated with the 1" diameter material in this product. So this is just a close visual representation of one manufacturer's product.

Perhaps when I get to creating a threaded rod with nut and washer options for both ends I will include a subroutine to accurately determine the two thread offset.

 

In light of all the hatches and snippets of code that I have borrowed from various places over the past 25 years,

attached is an updated working tool, sans icon. Past icon attempts have all failed miserably.

 

Wedgie Anchor.vso

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