vincentfs
(Vincent Shen)
May 4, 2021, 6:03pm
1
Hi there,
I was trying to do the following:
block = rs.AddBlock([obj], pt, str(obj), False)
rs.InsertBlock(block, pt)
where pt is the base point I want to keep, but the result always uses the Origin as the base point for blockinstance, and the inserted block will not be at the same place as the original object.
Is this a known bug or am I missing something? I am working on (7.5.21100.3001, 2021-04-10).
Best,
Vincent
dale
(Dale Fugier)
May 5, 2021, 12:04am
2
Hi @vincentfs ,
This seems to work:
import rhinoscriptsyntax as rs
def test_block():
rect = rs.GetRectangle()
if not rect:
return
pt = rect[0]
rs.AddPoint(pt)
points = list(rect)
points.append(pt)
rect = tuple(points)
id = rs.AddPolyline(rect)
blk = rs.AddBlock([id], pt, 'test_block', True)
rs.InsertBlock(blk, pt)
test_block()
What am I missing?
– Dale
vincentfs
(Vincent Shen)
May 5, 2021, 3:50am
3
Hi @dale ,
I think I found the problem here. When you run the script once, the rhino python definition for AddBlock
will do:
rc = scriptcontext.doc.InstanceDefinitions.Add(name, “”, base_point, geometry, attrs)
which passes in the base_point correctly.
But when you run the script again, since the block already exists, it will do:
rc = scriptcontext.doc.InstanceDefinitions.ModifyGeometry(found.Index, geometry, attrs)
which completely ignores the base_point.
So is there a way to modify the base_point for an existing block through script? Or I will have to reimplement the AddBlock
to make it work.
Best,
Vincent
dale
(Dale Fugier)
May 5, 2021, 11:49pm
4
Hi @vincentfs ,
RhinoCommon doesn’t have a method that will modify the insertion point of an instance definition. I’ve added an item to the wish list for this.
https://mcneel.myjetbrains.com/youtrack/issue/RH-64102
– Dale