November 2, 2023 at 6:21 pmStevenSubscriber
Hello, I am technically doing this in Speos, but I thought this would be the best forum for the question as it seems to be mostly about SpaceClaim API rather than the Speos specific API.
I am trying to import an object (from a file) and have it be pulled into the frame of reference by a user created origin. However, I cannot find how to specify the frame of reference in the import command
When done manually it works, but when I record the actions for use in a script it seems to leave out a critical component (i.e. the selectrion of the origin as the reference frame)
# Insert From File
importOptions = ImportOptions.Create()
DocumentInsert.Execute(r"path-to-file", importOptions, GetMaps("aa579405"))
In the documentation online and the space claim API documentation that came with the download, I cannot find any information on "GetMaps()" which seems to be the key. Additionally repeating the process manually with no other changes, the hex value in GetMaps changes (even though the result is the same).
- I have also tried importing and then using the OrientTo command as a work-around (see code snipit below), but this uses unit vectors to create the FoR and its unclear to me how these can be automatically linked to the origin
Any help is greatly appreciated
# Move Upto Selected Object
selection = ComponentSelection.Create(GetRootPart().Components)
upToSelection = Selection.Create(GetRootPart().CoordinateSystems.Axes)
anchorPoint = Move.GetAnchorPoint(selection)
moveFrame = Frame.Create(anchorPoint, Direction.Create(0.249572773159439, 0.176571112197779, -0.952121879401344), Direction.Create(0.176571112197779, 0.958453855953464, 0.224028677506199))
axis = HandleAxis.X
options = MoveOptions()
options.CreatePatterns = False
options.DetachFirst = False
options.MaintainOrientation = False
options.MaintainMirrorRelationships = True
options.MaintainConnectivity = True
options.MaintainOffsetRelationships = True
options.Copy = False
options.SnapAssociatedVertices = True
result = Move.OrientTo(selection, upToSelection, moveFrame, axis, options)
November 3, 2023 at 7:32 amAniketForum Moderator
Have you tried it without getmaps:
November 3, 2023 at 8:55 amStevenSubscriber
Using DocumentInser.Execute(...) with or without the "GetMaps" argument does import the object, but it does not associate it with the desired origin/reference frame
If I manually click the origin so it is selected before running DocumentInsert.Execute(...) (either with or without "GetMaps") then it will be imported to the correct reference frame, but that cannot be automated (because then I would need to click each time before import)
There must be a way to associate the import to a desired reference frame, since I am able to do it with the GUI, but I'm not sure of the command to make that association. I didnt see anything in the documents regarding the ImportOptions (although I could have missed it).
Is there a way to select an origin and make it active within a python script?
November 3, 2023 at 11:38 amAniketForum Moderator
Hi Steven, Is there any reason that this object cant be moved later to required position using move command?
November 3, 2023 at 12:11 pmStevenSubscriber
The main reason is that at the moment I am placing it in the world frame of reference, then using the OrientTo and MoveTo commands to get it into the right place. But there is a tendancy for the OrientTo command to cause the axes to be anti-allgned (i.e. parallel but in the opposite directions) so my objects can be placed at the origin, but are often pointed in the wrong direction.
I can circumvent this by doing some additional checking and rotations before hand to make sure that the angle between the "upto" vector and "object" vector is less than 90 degrees, but a much simpler and more elegant solution would be to just have the object loaded into the frame of reference of my reference origin.
I know its possible to place the object in the reference origin's frame of reference with the GUI (this is standard practice) but I dont know how to do this with python scripting (or if its possible) - it always defaults to the world frame of reference.
- You must be logged in to reply to this topic.
Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.
Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- No longer possible to import f3d with 2023?
- line bodies and surface body shared topology
- How to chang unit in Ansys Discovery 2023?
- ANSYSLI Exited or could not read server port ANSYSLI_FNE_PORT
- SpaceClaim Script: Selection by FilterByBoundingBox
- Assignment of revolute joint
- Max/min over time results in AIM
- Axisymmetric model – Rubber seal
- To change language in Ansys Discovery
© 2023 Copyright ANSYS, Inc. All rights reserved.