Jump to content
josue Corona

learning script

Recommended Posts

Can someone please write me a simple script of a simple 3D square with a hole extrusion being subtracted from the middle , I sent screenshot of example. (Btw its a circle not a polygon , some reason looks like a polygon) 

My idea is to start learning from here . thank you 

thank you.

1376006418_ScreenShot2019-10-15at11_00_22AM.thumb.png.a93531aa875ef93b43bcf2bbbf1b076f.png

Share this post


Link to post

The faceting is due to your OpenGL Options being set to Low. Try setting it to high and it will be much smoother.

 

Procedure Test;

Var	H1,H2,H3,H4: Handle;  {create handles to be able to access objects}
	N1: Integer; {create a variable to accept the result fo the subtract}

Begin
	Rect(-10,-10,10,10);  {draw rectangle}
	H1:=LNewObj;          {Get handle to rectangle}
	H2:=HExtrude(H1,0,5);  {extrude rectancle}
	Oval(-3,-3,3,3);      {draw circle}
	H1:=LNewObj;          {get handle to circle. Not I am reusing handle variable}
	H3:=HExtrude(H1,0,10);  {ectrude circle}
	N1:=SubtractSolid(H2,H3,H4);  {subtract the extruded circle from the exturded rect}
	AlrtDialog(Concat('The Result of the SubtractSolid is:',N1)); {optional: report return value of subtraction}
End;

Run(Test);

 

Share this post


Link to post

I see some script have parameters, 

when are they used ? 

are parameter always created after making the script?

I notice when making the script that option is grayed out. I will send a screen shot.

Edited by josue Corona

Share this post


Link to post

Parameters are only for plugin OBJECTS, These you create yourself if you want the user to enter a value such as dimensions of rectangle, radius of circle, etc. which will be listed in the Object Info palette.

 

Since the sample script is a COMMAND, it does not have any parameters defined.

Share this post


Link to post

Oh I understand, yea thats my next step to learn about perimeter. because for example in the Script that Pat gave me  i would like to make a parameter that will allow me to move the hole or down. 

One question when doing parameter there has to be extra script text that will combine the parameter with the script correct?

I don't know if that question even make sense sorry.

Share this post


Link to post

In my opinion, making a PIO is much more complicated than making a script. You could create a script that would display a dialog box, get a value, store that in a variable and then use that to modify how the script works.  Once you have it all working OK you could then relatively easily convert that to PIO and delete the dialog boxes and convert those variables into parameters.

 

There are just a lot of small details (from how you name variable/parameters to how you get into the code to edit it) that are more complicated in a PIO. If you add that level of frustration to just trying to learn to code, it will make it harder.

 

Plus, if you make a PIO, you can't just post a file for us to try and help. If you only post the code from the PIO, then either we have to create the PIO (including all of the parameters and defaults), or you have to send the PIO and we have to add it to our workspace to be able to help. I personally am much less likely to help with a PIO problem than with a script problem that I can work on quickly.

😉

 

 

Share this post


Link to post

I see, well I still need a lot to learn as far as scripting, so you might see me asking for help more that what I already do 😄 

I have a vector questions why do some object only show up in 2d plan but when I change be they disappear ? 

I will attach a screen record

 

 

Share this post


Link to post

I made it a plug in, but now it disappear , oh also when I did that the circle is no longer subtracted from the square . 

Share this post


Link to post

PIOs are Hybrid Objects meaning they have a 2D (screen plane) component that shows in Top/Plan and a 3D component that shows in all other views.(actually since there are now multiple 2D views that is not entirely correct, but you get the idea.

 

If there are no Screen Plane objects, then the 3D portion will show in Top/Plan as a wireframe. If there are no 3D objects (layer plane or working plane) the 2D will show in all views.

 

You must have some kind of 2D object in your PIO script that is making it a hybrid. Probably the same error in the code that is not doing the subtraction properly. Make sure you have Handles to the correct objects before you do the subtraction.

Share this post


Link to post

I noticed that you placed the pio in Plan View which is a 3D view. That explains to some degree why the extrude fails and the pio disappears. Since the extrude fails for whatever reason, you are left with a rectangle and a circle which are 2D objects and you cannot view these objects in Plan View. It is only when you  switch to Top/Plan that they reappear.

 

the solution would be to create a Hybrid object. That is create the rectangle with the circular hole first in Top/Plan view and then duplicate and extrude the copy to create the 3D part.

Share this post


Link to post

Creating Hybrid Object? The script made the object , do you mean like put a command that tells my object is a hybrid?

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.


 

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