Is there a way to prevent purge of certain blocks?

As in the topic - i want to prevent deleting blocks which were created by my plugin on purge command is there any way for doing this?

I mean of course i can listen to commands and take action like: Command_BeginCommand / Command_EndCommand to add those to doc and then delete them ( can’t just re-add them after purge cause guids will change ) but maybe there other better way to handle this discreetly?

Will temporarily hiding them during purge keep them from being deleted?

@Terry_Chappell what do you mean hiding? My blocks aren’t in doc they exist only in instance definition table thats my case - i pick them from table and process differently but since they are not in doc directly they can be purged and i don’t want that.

So you could put them in the doc and take them back after the purge. It seems you need a copy of them somewhere else. I do not use blocks in this way so I cannot give you very specific advice.

Well i said that in question post but i’m looking for more firendly way since adding plenty of block one after other will slow down things.

@dale @nathanletwory Guys some advice here ?

I’ll have to defer to @dale, this is something I know not much of.

Sure thing :wink:

@dale by the way i also wanted to ask is there a possibility to turn on snapping for objects drawn by Rhino.Input.Custom.GetPoint.DynamicDraw ?

@dale i also don’t understand why when i want to add block object to the scene it’s not using its insertion point but it takes center of base of its bbox ?

var instanceIdx = Rhino.RhinoDoc.ActiveDoc.InstanceDefinitions.Find(definitionId, true).Index;
Rhino.RhinoDoc.ActiveDoc.Objects.AddInstanceObject(instanceIdx, Transform.Identity);

Does C++ equivalent behave the same way? This is super important for me… As far as i understand getter is returning such data? This behavior is odd since when i convert entire definition to mesh it is exactly the mesh as it would use insertion point while when receiving instance insertion point isn’t taken into account? Am i missing something here? How do i access insertion point from instance definition ? Theres no such thing …
and on the other hand when adding definition insertion point is needed :disappointed:
Only way to access insertion point is to add InstanceObject do the scene then read its point and transform then block? Isn’t that just confusing?

Hi @D-W,

Not that I know of.

If you want object snapping in a GetPoint operation, then set the osnap modes you want before calling GetPoint.Get() and reset them when finished. You also add custom snap points to your GetPoint object (if that’s what need).

You need to pass a transformation, other than Transform.Identity.

– Dale

Thanks @dale! There could be also force since i get false in return probably due to that one object is in doc.

Other than Identity? Isn’t Transform.Scale(Point3d.Origin,1) the same as Identity? I would like to discuss this thing since it is weird that insertion point isn’t available in instance definition at all and adding instance behaves differently than everywhere else in the program (Insert command takes insertion point into account) don’t you think?

I hope you get my point i can’t even move it to proper position since base point isnt availible i have to add instance object then read its insertion point delete it and add again ? or transform each time after adding back to place ? This is bit nuts?

Look red one is extracted render mesh durig dynamic draw - gray one is added using ActiveDoc.Objects.AddInstanceObject(instanceIdx, Transform.Identity); And i exactly want to place it at Origin so i don’t get why i cannot use Identity besides any other equal transform like scale eg. or Transform.Translation(Vector3d.Zero) gives the same results …

[EDIT] I tried with Transform.Translation(Vector3d.XAxis) and it is still transforming it from bbox center instead of base point… i could move it right away back to point but its not availible from instance definition thats the issue… Besides its just unconsitent across api sdk - why render meshes of it are on place and definiton itself is not ?

[EDIT2] @dale i don’t have any clue why but … system reboot solved my issue - i don’t have any idea what went wrong but now after the reboot and solution rebuild all is working as it should :face_with_monocle: Weird… Sorry for the inconvenience if it will happen again i’ll report this send whole code + file.

Hi, @D-W,
is there any solution yet?
The best I can think of is to insert them at the xy-origin and lock them there.