Notifications
Clear all

[Closed] level 1 scripted plugin

Hi,

does anyone know why running the code below yields a result in the shape category list the first time you try. But yields no result after closing and restarting MAX and of course running the code again?

thnx,

ObiGert

plugin shape TM_Boxtruss
name: “BoxTruss”
category: “TM_Trussing”
( – plugin body

) [size=2]– end plugin body

[/size]

9 Replies
 xcx

Do you run it again after you start max again? If not make your script as macroscript.

yep xcx,

i run the code again and nothing appears in the category list, its a mistery to me

 rdg

Hi,

I think your code can’t work this way, because it is incomplete.

From the Max-Help file:

Scripted Shape plug-ins can only extend existing Shape plug-ins

You will need some more parameters.

The best way will be to copy the example from the [color=white][size=2]Scripted Shape [/color][/size][color=white][size=2]Plug-ins[/color][/size][color=white][size=2] entry in the help file and start from there.

Georg

Edited: use [/color][/size]genClassID[color=white][size=2] to generate your own classID – so your plugin will be unique.[/color][/size]

[color=white][size=2] [/color][/size]

hi rdg,

true, i saw that too…

But, I just want to generate some shapes and be on my way. The fact is I had that working until I reloaded the script the next time I ran MAX.

I think it has something to do with updating the plugin after changing the code because if I run that code, then change the superclass and run again it yields an error. I am new to MAXscript and certainly have no experience with this plugin stuff so maybe I am missing something about updating plugins?

genclassid() should not be necessary, for instance if i copy this from the max helpfile:

[left]plugin geometry foo_plugin_def[/left]
name:“FooBar”
category:“Scripted Primitives”

[left]( [/left]
local boxes, clickAt
tool create
(
on mousePoint click do
(
clickAt = worldPoint
boxes = for i in 1 to 10 collect box pos:([i*20,0,0] + clickAt)
#stop
)
)
rollout frab “Parameters”
(
spinner frab_value “Frabulate” range:[-1000,1000,20]
on frab_value changed val do
for i in 1 to 10 do boxes[i].pos = [i*val,0,0] + clickAt
)
)

[left]and change superclass: geometry to superclass: shape then it yields result in the shape category list[/left]

[left]save that script into a file, shut down MAX, restart MAX and reload (and evaluate) the code and it won’t appear in the shape category list anymore…[/left]

 rdg

*** INTERNET CONNECTION TOO SLOW – I missed your fragment. will check this later at home …


Hi ObiGert,

I startet with scripted plugins last week, after seeing them in the maxscript challenge.

As far as my expierence goes – simplePlugin and scripted material – updating the script during development time is no problem.

Just re-evaluate the code.
If there are errors max may crash – so save often.
Scripted Materials are more picky with errors … it is best to close the material editor when re-evaluating them.

If you save your working script in the scripts/startup folder , it will be accessible every time you start max.

I tried the fragment you posted and it did’nt even show up under shapes – MAX 7.5.
Depending on what you are trying to achieve, a macroscript may be also a solution.

Georg

Georg

Hi Georg,

thnx for hearing me out, I think I found the solution, try the following:

plugin shape shapename – Superclass, Variablename
name: “name” – Name
category: “shapecategory” – Category
( – plugin body
parameters main rollout params –
(
)
rollout params “rolloutname”
(
button createbutton “CreateButton”
on createbutton pressed do print “something”
)

tool create
(
)

) – end plugin body

This one will appear in the shape category list. And it will appear again when reloaded in a new session of MAX. The only necessity is the tool create () statement. Now it would be nice if someone could explain what this tool statement actually does…

ObiGert

 rdg

This part of code captures your mouse clicks an movements.
You can use the results as coordinates to build your mesh/spline/whatever.

In case of the posted Spline-Fragment, you can modifiy the “delegate”-Spline, that is the spline-class you are extending (e.g. rectangle).

Spline plugins extend an existing class.
I havn’t tried it yet.

Start modifing the “Scripted Shape Plugin” sample.
It is easier to understand as it is to explain …

 rdg

But after doing a search in this forum, I think it is easier to make your own shape using a macroscript or maybe a mousetool(?).

The main difference seems to be, it will not show up under create->splines …

 rdg

hm …
You can however convert the delegate to a spline and then mess with it:

plugin shape Extended_Rect
  
  name:"chaosRectangle"
  
  classID:#(0x15a3453e, 0x2a26a3f0)
  
  extends:rectangle version:1
  
  category:"Splines"
  
  ( 
  
  tool create
  
  (
  
  local startPoint
  
  on mousePoint click do
  
  case click of
  
  (
  
  1: startPoint = nodeTM.translation = gridPoint
  
  4: #stop
  
  )
  
  on mouseMove click do
  
  case click of
  
  (
  
  2: (delegate.width= abs gridDist.x
  
  delegate.length= abs gridDist.y
  
  nodeTM.translation = startpoint + gridDist/2.
  
  )
  
  3: delegate.corner_radius = amax 0 -gridDist.x
  
  4: (converttosplineShape $
  	addNewSpline $
  	for i=1 to 10 do(
  		addKnot $ 1  #smooth #curve [random 0 100,random 0 100, random 0 100]
  	)
  	)
  
  )
  
  )
  
  )
  
 

But addKnot & me where never really good friends …
I will have to get to know them … not tonight.

Georg