Quantcast
Channel: All Revit API Forum posts
Viewing all 66666 articles
Browse latest View live

Re: how to rotate a FamilyInstance around 3 axes

$
0
0

 

Hi dirk,

 

You can use like this

 

Let say familyinstance =fin

 

 1st  : Get Family Instance Location point (LP)

 2nd  : Now create unbound line according to direction(X,Y,Z) Like.
   
     XBasis=Line.Create(LP, fin.GetTransform().BasisX)
     YBasis=Line.Create(LP, fin.GetTransform().BasisY)
     ZBasis=Line.Create(LP, fin.GetTransform().BasisZ)

 

 3rd : Rotate Element
   
     ElementTransformUtils.RotateElement(document, element.Id, XBasis,Angle)
     ElementTransformUtils.RotateElement(document, element.Id, YBasis,Angle)
     ElementTransformUtils.RotateElement(document, element.Id, ZBasis,Angle)

 

Note: Can you explain more about "derived from Metric Generic"

 

This may help you


Re: how to rotate a FamilyInstance around 3 axes

$
0
0

 "derived from Metric Generic" just means I use the "Metric Generic Model.rft" template to generate the Family.

Re: How to insert Duct Fiting: TransitionsRectangularToRound by doc API ?

$
0
0
Hi ,
NewTransitionFitting is ok but it depend on PartType of Family and connector type you use to connect means. Round Duct must be connect with round Connector and Rectangular Duct to Rectangular Connector

You can try as below:

1 : Place Trasition family at specified position.
2.

Re: how to rotate a FamilyInstance around 3 axes

$
0
0
Oh,

I think you derived metrices for rotation.

I hope this will solve your issue.

Re: Transformation rules for familyinstance

$
0
0

Hi,

 

ElementTransformUtils.MoveElement  is use to displace a element from one location to another location.

 

You can use this  as below

 


1st :   Lp = FamilyInstance Location Point.

     You want to move at new Point that is newPosition;

after that do it like.

 

    XYZ newposition=new XYZ(1,1,1);

   XYZ oldPosition=Lp;


   XYZ MovePosition=null;


 

   MovePosition= newposition- oldPosition

   ElementTransformUtils.MoveElement(Doc, Elemnetid, MovePosition)

 

 

i hope this will work fine.

Re: Can't rotate element into this position

$
0
0

THanks Manish ,

 

I am trying to translate and rotate a Tunnel Lining Ring into Position. By Default, when it is instantiated, it is lying down on the XY-plane.

experimental_sector_15.png

 

I changed my code to use a Bound line.

By Default the BuiltInParameter "Always vertical" is checked. When I run the Rotation on that Family Instance, the ring stays flat on the xy-plane, because the tunnel lining ring instance is "always vertical".

 

So I uncheck it in the code using:

 

doc.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_ALWAYS_VERTICAL).Set(0);

 

However, then when I try to turn the ring upright, I get this error:

 

"Elemente können nicht in diese Position gedreht werden."

 

== Elements cannot be turned into this Position.

 

I would have thought that unchecking "Always vertical" would cause the Element to rotate, so this is confusing.

 

dirk

Re: Can't rotate element into this position

$
0
0
Hi Dirk,

I guess...

Always vertical or Horizontal is set for fix the orientation of instance while place. You getting error "Elements cannot be turned into this Position" it means while rotate constraint is violated you need to correct Position and orientation of instance.

Re: Can't rotate element into this position

$
0
0

Hello Manish,

 

thanks for your reply. I am trying to turn the ring upwards in order to correct the orientation. That is when the error comes.

I don't understand why this error comes when the constraint is turned off:

 

doc.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_ALWAYS_VERTICAL).Set(0);

 

dirk


Re: Can't rotate element into this position

$
0
0

Wouldn't it be nice if your requirement included the tunnel ring always to remain vertical?

 

Then you could make use of the functionaqlity provided by Revit, and redesign your family to create the tunnel ring in the XZ plane instead of XY.

 

Unfortunately, I assume that you sometimes need the ring to be slanted as well.

 

But wouldn't it be nice and powerful to make full use of all the available built-in functionality provided by Revit?

 

Cheers,

 

Jeremy

Re: Can't rotate element into this position

$
0
0

Hello Jeremy,

like you say, the ring needs to be rotated around all axes, including its own longitudinal axis (i.e. 4 rotations), since the axis of the tunnel is a 3D curve, and the lining is constructed by ratcheting the rings around their own longitudinal axis after they have been positioned.

In my case the Revit constraints are just a problem to be overcome. Designing it in the XY plane has the benefit of being able to control the conicity and the built in elements by checking the Family.

dirk

Re: Drag and Drop between Revit and API

$
0
0

Hi Jeremy,

I want to first thank you for your very easy to follow posts on drag and drop. I found them easy to implement for a very used add-in that i put into production a few years ago.

 Now I am considering additional functionality, I wan't to drag and drop a group of files from a list, that I will likely add tag information in a list view and place them a set distance apart. 

Firstly can drag and drop take coordinate data say relative position into the ui placement so that a user can click and the families are placed a set distance apart?

If not should I implement some other promptforuserplacement() method or the like?

Is this dangerous? as I saw your cautionary post on drag and drop that highlighted the dangers associated with messin with the ui.

 

cheers,

Phil

Re: Drag and Drop between Revit and API

$
0
0

Dear Phil,

 

That sounds like a perfectly valid idea and approach.

 

I don't see any specific dangers associated with what you say.

 

Once you have determined the master insertion point, you can probably place the additional instances at set distances directly using the various suitable NewFamilyInstance overloads.

 

Cheers,

 

Jeremy

Re: Can't rotate element into this position

$
0
0

Dear Dirk,

 

1. Any rotation you desire around "all axes" can be achieved with just two rotations: first, one of 0 to 180 degrees around the X axis to raise or lower your instance out of the XY plane, followed by one of 0 to 360 degrees around the Z axis.

 

2. Check out quaternions:

 

https://en.wikipedia.org/wiki/Quaternion

 

They provide the most powerful and easy-to-use rotation functionality in 3D space.

 

That is why they are popular in game development.

 

They should be used everywhere.

 

Are CAD developers less competent than gamers?

 

Cheers,

 

Jeremy

Re: Keynote creation within API - still not possible?

$
0
0

Dear Dennis,

 

I'm checking with the development team for you...

 

Cheers,

 

Jeremy

Re: InstanceVoidCutUtils.AddInstanceVoidCut() is disabled to called from the Upd

$
0
0

Dear Marcelo,

 

Thank you for your report and wish and effective sample material. That helps a lot.

 

I submitted it to the development team.

 

This lies somewhere between a change request and a wish list item.

 

All wish list items should be submitted to the Revit Idea station.

 

However, I went ahead and treated it as a change request and logged the issue REVIT-117931 [InstanceVoidCutUtils.AddInstanceVoidCut disabled in IUpdater -- 13267397] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team, and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

I hope this helps.

 

Cheers,

 

Jeremy


Family Instance Filter

$
0
0

Honestly, sometimes I feel so daft; is it me or the API? I want to return a list of all Family Instances by name. All samples, including the Revit API docs, pass a name, but this is in fact the Type name. As the Type name is not unique (i.e. "Type 1") and can be used by different Families, this seems to be incorrect. The following is the example from the Revit API Docs:

 

// Use ElementClassFilter to find family instances whose name is 60" x 30" Student
ElementClassFilter filter = new ElementClassFilter(typeof(FamilyInstance));
// Apply the filter to the elements in the active document
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.WherePasses(filter);
// Use Linq query to find family instances whose name is 60" x 30" Student
var query = from element in collector
where element.Name == "60\" x 30\" Student"
select element;
// Cast found elements to family instances,
// this cast to FamilyInstance is safe because ElementClassFilter for FamilyInstance was used
List<FamilyInstance> familyInstances = query.Cast<FamilyInstance>().ToList<FamilyInstance>();

 

To correctly return a list of FamilyInstances, surely the collector needs to be passed the following, in order:
1. Category
2. Family Name
3. Family Type Name

 

I have been unable to find an example, and I have been unable to assemble a filter statement to correctly limit the returned instances. Am I missing/overlooking something? Can anyone point me in the right direction? Thanks, Dale

Re: Can't rotate element into this position

$
0
0

Hello Jeremy,

 

thanks, for the info, I am aware of Quaternions and have used them in the past. Yes they are powerful as a compact way of writing the Transformation Matrix. But they are not the reason why I am not making headway.

I have a Routine which implements the rotations, and it works successfully with a simple adaptive tunnel ring.

The Problem is that these Rotation mechanisms do not work with FamilyInstance of an ordinary Family, because there are constraints in Revit which hinter rotations of a FamilyInstance about all 3 axes. This is where I am currently stuck. When I try to rotate a FamilyInstance obtained from the template "Metric Generic Model.rft", the "Always vertical" constraint is checked. so when I try to rotate the ring with this constraint checked, it does not react.

When I uncheck the constraint using

 

doc.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_ALWAYS_VERTICAL).Set(0);

 

the Rotation fails with the message

 

"Elements cannot be turned into this Position"

 

I do not understand what this message means. I've looked at the ring with a CAD Operator. He managed to turn the ring in the Family Editor, but could not do so as a FamilyInstance in a project. It then says that the ring is locked. What does that mean?

 

The other Option would be to generate the ring as an Adaptive Family using the "Metric Generic Model Adaptive.rft" template. But that template does not allow constructs such as Revolution elements.

 

So either way I am stuck.

 

dirk

Re: InstanceVoidCutUtils.AddInstanceVoidCut() is disabled to called from the Upd

$
0
0

Hi Jeremy,

 

what about a workaround:

if the IUpdater is triggered, it fills a list with ElementIds to be processed.

Then it registers for the Idling event.

 

When Revit idles, the list of ElementIds can be processed in a valid Transaction.

After that, unregister the Idling and you are done.

 

 

Rudi

Re: Can't rotate element into this position

$
0
0

Dear Dirk,

 

The best and most effective way forward is for you to create a reproducible case in which you prove that the desired orientation can be achieved manually through the user interface, and that the corresponding API manipulation fails.

 

If you cannot achieve what you want in the UI, then it is normally not possible in the API either.

 

Please provide the following:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Cheers,

 

Jeremy

Re: InstanceVoidCutUtils.AddInstanceVoidCut() is disabled to called from the Upd

$
0
0

Dear Rudi,

 

Sounds good and doable to me!

 

Thank you!

 

Cheers,

 

Jeremy

Viewing all 66666 articles
Browse latest View live