Component definition --> save insertion_point
-
Hello my friends,
Here is a question about saving a componentdefinition.
<span class="syntaxdefault"><br />point </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">definition</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">insertion_point </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> point<br />entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">definition</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">save_as </span><span class="syntaxstring">"E;\\def.skp"<br /></span><span class="syntaxdefault"> </span>
I set the insert_point of the componentdefinintion an then save the definition.
The insertion_point is not saved with the definition.
How can I save the insertion_point within the E:\def.skp ?Thnxx
-
I figured it out by myself!
Just create a new comonentinstance like this:
<span class="syntaxdefault">point </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">def </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">definition </span><span class="syntaxcomment"># assuming entities[0] is a component instance<br /></span><span class="syntaxdefault">def1 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">definitions</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"name"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">new point<br />def1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_instance</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">def</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> tr</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /><br />def1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">save_as</span><span class="syntaxstring">"E;\\def1.skp"</span><span class="syntaxdefault"> </span>
Now a new component is created containing a component instance with its transformation.
Changing the 'point' variable results in a different insertion point
for the imported component.Anybody for improvement on this??
-
Don't use '
def
' as a reference/variable - it's a reserve word - used to make methods... -
TIG,
Advertisement