How can I draw a viewport from a polyline?

Hi, I’m trying to create a viewport from a polyline. I found the following in the AutoCAD API:

image
https://help.autodesk.com/view/OARX/2022/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_GraphicsInterface_Viewport_Viewport

But I have no idea what an unmanagedPointer is. I’ve already researched it on the internet and on the AutoCAD website but I can’t find anything explaining.

I wouldn’t use that constructor. Just use the basic one.

Viewport vport = new Viewport();

Sorry, I just forgot to make it clear in my message. But I wanted to create via python script inside Dynamo.

Also, this is the class you should reference.

https://help.autodesk.com/view/OARX/2022/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_Viewport

After creating the viewport, set the NonRectClipEntityId property to the Polyline’s Object ID, and then set NonRectClipOn to true.

I’m not so sure Dynamo is the best method/tool to accomplish this. You could write a super short one line script to do this quicker than opening dynamo player up and running it.

@jehart while you bring up a fair point, I have to push back a little bit. I had a very similar response awhile ago to a question about using Dynamo to sum up all the lengths of Polylines.

…and Paolo put me in my place:

So I have to repeat it here: yes, LISP could cut it, but where is the innovation in that? The question was posted on the Dynamo forum, which means that @andre.demski is looking for a Dynamo solution. Also, we don’t know the extent of the workflow that this would be fitting into. If it was just a one-off to create a Viewport from a Polyline one time, then sure, a simple one-liner could work. But what if this is part of a multi-step approach that is, for example, creating layouts, viewports, and annotation for an entire project? Or what if @andre.demski is just wanting to break away from a 50+ year-old programming language and try something new?

I say all this with the utmost respect, and I hope to not offend you. But we all need to help each other out to push the boundaries of our industry and explore new workflows.

With all that said, @andre.demski how are you coming on this? Do you need any more help?

1 Like

@mzjensen i didn’t take that comment cross at all my man. I totally respect your comment.

Before you had typed that response, I thought about it too. I came to the same conclusion as you about using dynamo to create a viewport or multiple viewports also (or any tool for that matter).

While it can be accomplished with LiSP, as you mentioned, it’s an antiquated programming language that’s been around for a long time (1960).

Totally agree it’s great to explore new workflows to create tools. For this I’ll stick to my trusty LiSP routine I created a few years ago for viewports, but will explore breaking out of my comfort zone more often.

Great civil discourse is what separates this group from some of the other toxic forums online (AUGI & The Swamp).

2 Likes

Agreed. There’s no need for that.

2 Likes